- Home /
Question by
Next Beat Games · Aug 11, 2013 at 07:45 PM ·
c#function callnull referenceno error
c# null script reference calls function with no error
Hello. I have the following code
...
else if( mSelectedTransform == mInputManagerScript.avatarParentScript.bodyScript.shirtColliderTransform )
{
Debug.Log ("SHIRT " + mInputManagerScript.avatarParentScript.shirtScript);
mAvatarShirtScript = mInputManagerScript.avatarParentScript.shirtScript;
Debug.Log ("mAvatarScript should be null reference");
mAvatarShirtScript.InputBegin ();
if( mAvatarShirtScript == null )
Debug.Log ("YUP");
}
...
I run this when mInputManagerScript.avatarParentScript.shirtScript is null. The output I get is:
Shirt null
mAvatarScript should be null reference
YUP
shouldn't I get an error when calling InputBegin() ?
Comment
If InputBegin were static, then there would be compile error.
And regarding this specific behavior - normally you should get an error indeed. Are there any other errors/warnings in Unity console above the output you posted?