I want to reference a GameManager script from a different Scene (Level 1) in my Main Menu Scene. Each level has it's own instance of GameManager with different variables so Don'tDestroyOnLoad won't work from my understanding as I wouldnt want one scenes Gamemanger script being used as the Gamemanager script in a different scene. I tried having a Scene variable and doing FindObjectOfType on it but FindObjectOfType isn't a method useable on a Scene variable. It seems it only looks inside the current scene.
#Searching in a different Scene from the current Scene a Script that is Instanced
1 messages · Page 1 of 1 (latest)
findobjectoftype works in all scenes 🤔
ideally you wouldn't want a gamemanager in your main scene and one in each level
you might want 1x GameManager existing in DDOL as a Singleton and then some kind of LevelController that exists per level
FindObject(s)OfType should search across all loaded scenes(and not just scenes, but otherwise loaded objects, like SOs). Unloaded scenes simply don't exist, so there's nothing to find or reference. In any way at all.
it searches throughout all scenes even the ones not loaded for the first object of type are you saying? My understanding was that it just searched through the current scene
I haven't learned it this way but i'll look into it. May be a lot of overhead to change though
So if I haven't played a scene yet it wont be regarded as loaded if im understanding correctly?
Yes. Or if you loaded a new scene non additively. The prev scene would be unloaded.