Horje
reference to gameobject in different scene unity Code Example
reference to gameobject in different scene unity
public Canvas menu;

// Start is called before the first frame update
void Start()
{
    //not in OnEnabled since we want these methods to be called on startup
    SceneManager.sceneLoaded += OnSceneLoaded;
    SceneManager.sceneUnloaded += OnSceneUnloaded;
}

void OnDestroy()
{
    //not in OnDisabled since we want these methods to be removed only when destroyed, not switched out of
    SceneManager.sceneLoaded -= OnSceneLoaded;
    SceneManager.sceneUnloaded -= OnSceneUnloaded;
}

//when a scene is loaded, make this canvas invisible
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
    menu.gameObject.SetActive(false);
}

//when a scene is unloaded, make this canvas visible again
void OnSceneUnloaded(Scene current)
{
    menu.gameObject.SetActive(true);
}




Csharp

Related
symfony debug bar Code Example symfony debug bar Code Example
faire des séparateurs millers en c# Code Example faire des séparateurs millers en c# Code Example
firepower 4125 License update Code Example firepower 4125 License update Code Example
Debug output to console and a log Code Example Debug output to console and a log Code Example
start wpf application when windows start Code Example start wpf application when windows start Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9