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
Asked
Active
Viewed 90 times
0
-
This description was confusing to me. Could you describe it with more names and details? – Daniel Feb 22 '21 at 03:24
-
Hello, @Daniel, i added the screenshot – Alex Cosmic Feb 22 '21 at 03:36
-
Best Score is a text game object in MainMenu Scene's canvas. And i can't drag and drop it to Game Master script, attached to Game Scene's canvas – Alex Cosmic Feb 22 '21 at 03:40
1 Answers
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