So my console recommends I check if a gameObject has become null, how do I go about doing so? I checked the scripting references, only to feel completely lost under searching null. lol Thanks again to incredible support.
if (someGameObject != null) {
// do something with someGameObject
}
–Eric
if (theGO != null) {
}
For future reference this is more of a language thing than the unity API, which is probably why the script reference was not much assistance.
Right, probably the msdn docs would have been more useful. Because they cover the c# syntax.
thank you erich, dan and nps. Your examples made perfect sense to me. You all have been very helpful once again. ![]()
For convenience, Unity objects, like GameObjects or Transforms can also be evaluated for null directly, like this:
if (myObject) // not null
else // null
That doesn’t work on everything though, so the suggestions above are probably better for general usage.
Cheers