❔ Access things from different scene in Unity

I have a Class Selector scene that has a Class Selector Script component (MonoBehaviour) attached to one of it's GameObjects, see first screenshot. I have a Stat Selector scene that has a Stat Selector Script component (MonoBehaviour) attached to one of it's GameObjects. The Stat selector holds a field of type ClassSelector and I want to assign to it the ClassSelector from my ClassSelector Scene, how can I do that?
8 Replies
Florian Voß
Florian VoßOP2y ago
Florian Voß
Florian VoßOP2y ago
the GetRootGameObjects()throws ArgumentException: "The scene is invalid" I was hoping I could search through that for the GameObject and the Class Selector Script component attached to that GameObject Debug.Log(classSelection.rootCount) prints 0 for some reason, I dont understand why.
Anton
Anton2y ago
You have to load it, then wait a frame or two, then query the objects. If you're doing it in the editor, use a prefab instead and reference it in both places
Florian Voß
Florian VoßOP2y ago
but if I load the scene then I have two scenes loaded and displayed 🤔
Cattywampus
Cattywampus2y ago
You're doing it the wrong way either you want a scriptableobject or just save it to json also why you make a separate scene just for the stats?
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Florian Voß
Florian VoßOP2y ago
its a StatSelector scene. The User can assign different randomly generated values to different character stats such as intelligence, strength...
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server