- Home /
dontdestroyonload object references
Hey guys I need a little help understanding how to work with dontdestroyonload objects that I placed in my first loaded scene, from a future scene.
I understand that the objects have never been destroyed but since they're not present in the hierarchy in a future scene, I can't use unity's drag and drop reference system.
Does this mean I have to do everything through code? Basically can I assume the object is in the hierarchy even though it's not actually there, and do searches for the name to create a reference in code?
Or am i missing something?
Thanks.
If you play the first scene and pass to second scene, the objects with dontdestroyonload will still remain. You can see them in hierarchy only while testing the scene. Why do you keep the objects from the first scene?
wow you're absolutely right it does stay! i had no idea...
I'm using the NeatPlug Social Networking Plugin which comes with 2 prefabs that must be placed in the first scene and are not destroyedonload. One of them has a script that provides facebook events that I need for my facebook buttons in future scenes.
Due to a slight delay between clicking a button and the facebook window opening up, I need to turn off all the buttons once one is clicked to prevent the user from pressing another button quickly before the window opens up. I need the facebook events to let me know that some procedure was done so i can turn the buttons on again. I was confused as to how to connect the script to the buttons if they're not in the same scene, but now i know they are actually in the hierarchy.