Skip to main content
added 4 characters in body
Source Link

Newbie Unity3D/C# developer here.
I've tried learning Unity3D during my JuneMay/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?

Newbie Unity3D/C# developer here.
I've tried learning Unity3D during my 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?

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?
Errors
Source Link

Newbie Unity3D/C# developer here.
I've tried learning Unity3D during my 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, `GameObject``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?

Newbie Unity3D/C# developer here.
I've tried learning Unity3D during my 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, `GameObject` 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?

Newbie Unity3D/C# developer here.
I've tried learning Unity3D during my 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?
Source Link

Unity3D - GameObject as a static function

Newbie Unity3D/C# developer here.
I've tried learning Unity3D during my 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, `GameObject` 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?