Accessing object in a different level

Hi, Can I access an object in a different level?

My context is this…
I just implemented my Inventory control where i can pick up an object and use it later… Once I picked up, I just set the object active to false, and when i use it, I set it back to true (And set it’s transform near to the player and parent it). I know i shoudl be destroying and re-instantiating… But problem is, I implemented my inventory control using the new GUI, and my OnClick function that i register to it is part of the original object’s “InventoryItem” script. So, If i delete the object, and then click the item in my inventory window, it just doesn’t find the script. So I had to disable the object (I which case, the script is called fine). This works OK.
My only concern here is… I must be able to use an object i “picked up” at different level. i.e, I had set it disabled at a different level. Can I acess that object and move to my current position? Or do i just have to re-instantiate in my new level?


You can use dontdestroyonload methods, or you can save information on playerprefs and check it in start function of each scene.

Save it as an int, if it’s true, make it 1 (if false make 0). And in a start function make it check for playerprefs, and enable/disable that object base on that.

Another method is to use static bool. You would toggle it and for each scene it will have same value. But you will have to make different booleans for each item.