I have a property in a MonoBehavior, defined in the following way:
public GameObject whatever = null;
I set it to an actual GameObject reference on some of them, leave it blank in others. Basically, its an optional property. Now, the craziest thing happens when I test it in the program:
Debug.Log(whatever + " " + (whatever == null));
This prints: “null False”. I have no idea how to proceed. All I want is to be able to null test it in code.
The following Test Behavior exhibits this issue and requires no further code:
using UnityEngine;
using System.Collections;
public class TestBehavior : MonoBehaviour
{
public GameObject whatever;
// Use this for initialization
void Start ()
{
Print(whatever);
}
public void Print<T>(T anObject)
{
Debug.Log(anObject + " " + (anObject == null));
}
}