Newbie Unity3D/C# developer here.
I've tried learning Unity3D during my May/June college vacation and came across a problem:
Code 1:
CameraObj returnVoid;
void Start ()
{
returnVoid = GameObject.Find ("Main Camera").GetComponent<CameraObj> ();
returnVoid.ComponentType ();
}
Code 2:
GameObject returnDirectLight;
void Start ()
{
returnDirectLight = GameObject.Find ("Directional Light");
Debug.Log (returnDirectLight.GetComponent<DRLight>().directionString);
}
CameraObj is my custom component.
As far as I know, GetComponent is actually a public method. I understand the logic behind Code 2. What I fail to understand is Code 1. How does GetComponent become a static function here? Does it become abstract in my CameraObj class?