0
Under Review

MissingReferenceException in ComponentHolderProtocol

PET 3 years ago updated by Lazlo Bonin (Lead Developer) 3 years ago 3

I'm using this node made by Jason:


However this problem is also with any kind of Wait loop. If the GameObject get's destroyed while a Wait loop is running, You get this error:

MissingReferenceException: The object of type 'StateMachine' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
Ludiq.ComponentHolderProtocol.GameObject (UnityEngine.Object uo) (at C:/Users/Lazlo/Projects/Ludiq/Ludiq.Core/Runtime/Utilities/ComponentHolderProtocol.cs:29)
Bolt.ValueInput.GetDefaultValue ()
Bolt.ValueInput.GetValue (Ludiq.Recursion recursion)
Bolt.ValueInput.GetValue ()
Ludiq.XGettable.GetValue (IGettable gettable, System.Type type) (at C:/Users/Lazlo/Projects/Ludiq/Ludiq.Core/Runtime/Utilities/IGettable.cs:14)
Ludiq.XGettable.GetValue[GameObject] (IGettable gettable) (at C:/Users/Lazlo/Projects/Ludiq/Ludiq.Core/Runtime/Utilities/IGettable.cs:19)
Bolt.GetVariable.Get (Ludiq.Recursion recursion)
Bolt.Unit+<>c__DisplayClass56_0`1[System.Object].<ValueOutput>b__0 (Ludiq.Recursion recursion)
Bolt.ValueOutput.GetValue (Ludiq.Recursion recursion)


Fair enough. I understand that Wait Loops are working on a separate "layer", but... would it be possible to get a reference to the object that it's been destroyed and still has this Wait Loop? It's super hard to debug this :(

Thanks


Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
+1

Well to be fair, it's probably because I didn't add a OnDestroy call on the object owner. That's a pretty important fix, I'll do that tonight. Should only take a few minutes, just not able to get on my computer for a few hours. Our Waits have a couple different things. I don't think native actually holds any reference to the last Coroutine ran, because it is async.  

So if it's Async, it's a matter of me using a list for references, instead of a single instance reference.

That would be great. I been having that "Break" linked to an event, and whenever an Unit is dying it's running the "break" event on SELF. Problem is that ... there is still someone that only sometimes is generating this, and I don't know who :D

Under Review

I think there's also a small pseudo-null check missing on the native end in the ComponentHolderProtocol class, I'll look into it!