Let's take the Find method out for a spin and retrieve the Directional Light object from LearningCurve:
- Add two variables to LearningCurve underneath camTransform—one of type GameObject and one of type Transform:
public GameObject directionLight;
private Transform lightTransform;
- Find the Directional Light component by name, and use it to initialize directionLight inside the Start() method:
void Start()
{
directionLight = GameObject.Find("Directional Light");
}
- Set the value of lightTransform to the Transform component attached to directionLight, and debug its localPosition. Since directionLight is its GameObject now, GetComponent works perfectly:
void Start()
{
directionLight = GameObject.Find("Directional Light");
lightTransform = directionLight.GetComponent<Transform>();
Debug.Log(lightTransform.localPosition);
}
Before running the...