missing (transform) vs none: how to code this or query for it?

Hi,

In the inspector, the drop down field used to reference transform or game object knows the difference between "none" and "missing",

that is if I delete a reference that was hooked to a public var in a script, the inspector fields shows "missing (transform)". This is very good, but I need to catch this now within my code to act upon this. I have scripted something that works, but it's really, really hacky and involves scanning all transforms... not very nice, hopefully there is a better way.

I wonder how this is coded and if the api ( editor or general) expose a function or flag for this, I failed to find anything on that matter in the help.

Thanks for your help,

Bye,

Jean

Probably a memory thing. A reference marked as "null" would cause a none, while a reference to an object that's either marked for garbage-collection, or been garbage-collected, or something to that effect, would cause a missing.

The question is, do you really care about the difference or do you just want to know when your object has, for example, lots its target, and take action? If it's the former then I'm afraid I'm of no help. If it's the latter, then there are at least two ways to handle it. The easy way is to check either periodically, or on access, whether the object is there or not. The smart way is to code events using C# that your script can subscribe to, such as, say "OnLostTarget", that you can then take action on (in this case, trying to reacquire a target). The MSDN has info on how to set up a basic event system. This could also be accomplished in a simplified form using Unity's SendMessage function, but that's got a few disadvantages compared to events.