I was trying to use #pragma strict and got this error:
Cannot convert '(UnityEngine.Component)' to 'GroundCheck'
It's referring to this snippet:
function start (groundCheck : GroundCheck) : GroundCheck {
if (groundCheck == null)
groundCheck = GetComponentsInChildren(GroundCheck);
if (groundCheck == null)
groundCheck = transform.Find("GroundCheckCollider").GetComponent(GroundCheck);
return groundCheck;
}
And that is the only custom function inside GroundCheck.js
Needless to say, without pragma I get no error. And the second if also doesn't bring any error.
So, how can I fix this?
I actually came up with a solution, but I'm not sure if it's adequate:
function Parse (v) : GroundCheck {return v;}
function start (groundCheck : GroundCheck) : GroundCheck {
if (groundCheck == null)
groundCheck = Parse(GetComponentsInChildren(GroundCheck));
if (groundCheck == null)
groundCheck = transform.Find("GroundCheckCollider").GetComponent(GroundCheck);
return groundCheck;
}