0

There are 2 scenes in my app and the script, attached to canvases in both of them. I add a variable in script, and wanted the game object from one of scenes be it's value - drag and drop object to the inspector, where the variable field is. In scene, where object is belong to, i was able to do this and have no emty variable fields, but i can't drag and drop this object to the variable field in another scene and in script, attached to canvas in this scene there is an empty field. Before that action script worked, so i suppose that's the cause. How to fix this? Screenshot

1 Answers1

0

Well it sounds like you are trying control your UI, so you ahve the same script on the canvas object for two scenes. The way I would fix this, and how control my UI on all scenes is:

  • Delete the Canvas on the second scene.

  • On the first Scene add a script that has:

    void Awake() => DontDestroyOnLoad(this);

This will allow the object in the first scene to go to the second scene.

CorrieJanse
  • 2,374
  • 1
  • 6
  • 23