Is there a way to make sure the directional light for a scene is where the skybox's "sun" is? Thanks.
Answer by Adam Rademacher
Oct 06, 2010 at 04:12 AM
You'll have to do it manually by positioning the directional light where the "sun" should appear to be for the player. The good thing is that the directional light can be outside the playable area so that it always appears to be in the same place as the sun in the skybox. Turning on your sky in the scene view can help you align it properly.
I had mine aligned with the Directional Light "close" to the scene's main action. Using the tip here, I simply multiplied all Position transforms by 100, and it was perfect.
So basically, to align with the default Skybox, my directional light was at XYZ -20, 47, 34. I changed that to -2000, 4700, 3400 and its perfect from all feasible angles and positions within the playable scene.
Answer by mouurusai
Sep 06, 2012 at 01:27 PM
public class DirectionHelper : Editor
static void SetDirection()
Transform selected = Selection.transforms;
selected.forward = -SceneView.lastActiveSceneView.camera.transform.forward;
This worked wonderfully for me. Much easier then setting it manually like I was before.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
3 People are following this question.
Sun shafts from the sun
strange textures with directional light[solved]
Lightmapping outdoor scene not working, no shadows
Origin does not reset to 0,0,0, light component adds improperly
transform.position.y and point light