- Home /
Sun coordination with Skybox
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 $$anonymous$$e 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
using UnityEngine;
using UnityEditor;
public class DirectionHelper : Editor
{
[MenuItem("Healpers/SetLightDirection")]
static void SetDirection()
{
Transform selected = Selection.transforms[0];
if(!selected)return;
selected.forward = -SceneView.lastActiveSceneView.camera.transform.forward;
}
}
This worked wonderfully for me. $$anonymous$$uch easier then setting it manually like I was before.
Your answer
![](https://koobas.hobune.stream/wayback/20220613074843im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Sun shafts from the sun 1 Answer
ortographic spotlight ? 1 Answer
Directional Light on Terrain 1 Answer
Origin does not reset to 0,0,0, light component adds improperly 1 Answer