Page 1 of 1

Loading Breaks Public References

Posted: Fri Nov 08, 2024 10:01 pm
by Aephrosi
Whenever I load (currently with SaveSystemMethods) I am getting:

Code: Select all

MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
On public references that are visible in the inspector. This only seems to happen on functions that are called through Lua.RegisterFunction.
SaveBroken.png
SaveBroken.png (67.69 KiB) Viewed 52 times
If I do a:

Code: Select all

player = GameObject.Find("Player")
before trying to use it, everything proceeds just fine. Problem is, I have many other game objects that need to maintain that reference.

Thanks in advance.

Re: Loading Breaks Public References

Posted: Fri Nov 08, 2024 10:23 pm
by Aephrosi
Can confirm that it looks like it has to do with running it straight through the Lua.RegisterFunction call.

If I instead have the dialogue system enable an separate object with a Usable trigger, I can go to that object to trigger the code with the usable.

Re: Loading Breaks Public References

Posted: Sat Nov 09, 2024 9:14 am
by Tony Li
Hi,

It may be related to Don't Destroy On Load GameObjects such as the Dialogue Manager. Please see: How To: Manage Player Controls and Scene Changes for an explanation (with images) of what I mean.

Re: Loading Breaks Public References

Posted: Sun Nov 10, 2024 12:29 am
by Aephrosi
Great! thank you. I'll stay with my work-around for now, but if I end up needing this, it's good to have as a reference.

Re: Loading Breaks Public References

Posted: Sun Nov 10, 2024 1:13 am
by Tony Li
Sounds good!