-1

Let's say I have scene A and Scene B and there is one object in each scene. There is also a script attached to the Object in scene A and I wanna hide the object in scene B trough that script.

If I'd do "public GameObject ObjectB;" I couldn't drag ObjectB in cuz it's in another scene.

Also tags don't affect other scenes.

Hope u can help. Also sorry if the solution is obvious, Im new to unity

MF714
  • 153
  • 7
  • I would refer you to [this answer](https://stackoverflow.com/a/60408573/7111561) .. of course there are multiple possible solutions as well in the others .. in particular `static`s might be a quick and simple one ;) – derHugo Dec 27 '20 at 17:22

1 Answers1

0

To transfer data between scenes, use ScriptableObject. Create a variable that is responsible for activating this object in all scenes and check it when loading the scene

[CreateAssetMenu(fileName = "Data", menuName = "ScriptableObjects/SpawnManagerScriptableObject", order = 1)]
public class SpawnManagerScriptableObject : ScriptableObject
{
    public bool isObjectEnabled;
}