How would I reference a game object that is in another scene.
I’m using scriptableObject as manager, as long as the game object i try to get still exist
Normal gameobjects can’t be accessed from other scenes, because they are destroyed when the scene ends. If you use DontDestroyOnLoad, then it’s still in your scene. Not sure what you’re asking, exactly. Static classes and variables might help what you’re trying to do.
If you’re doing additive scene loading, the ScriptableObject approach that @Putcho posted above is one way of making a central “Hey everybody, let’s share this object and tell everybody where everything is!” type construct.
Another way is with singletons: Some super-simple Singleton examples to take and modify:
Simple Unity3D Singleton (no predefined data):
Unity3D Singleton with Prefab used for predefined data:
These are pure-code solutions, do not put anything into any scene, just access it via .Instance!
If it is a GameManager, when the game is over, make a function in that singleton that Destroys itself so the next time you access it you get a fresh one, something like:
public void DestroyThyself()
{
Destroy(gameObject);
Instance = null; // because destroy doesn't happen until end of frame
}