What I’m trying to do inside this script is to load a different scene, and find the canvas from that scene and enable it.
I already know how to enable the canvas from the same scene but the issue is how can i find and enabled a canvas from another scene.
I tried SceneManager.LoadScene(scenename); to change scene so what should I add or modify?
Can someone help me?
I suggest making your function a coroutine and then using LoadSceneAsync. Then you can wait for the scene to finish loading like in the Unity example:
Afterwords you can find the object multiple ways but the main one being the Find method:
You should use SceneManager.LoadScene(scenename, LoadSceneMode.Additive); That way your current scene will still be intact so you can clone the canvas and put it under an object in your current scene, then SceneManager.UnloadSceneAsync(scenename) to unload the rest.
Drag your canvas into the Assets Folder then Add these to your script that is attached to an empty GameObject in the scene that you want to spawn the canvas:
//drag your canvas Prefab(That you dragged into your assets folder) in the Inspector
[SerializeField]
private GameObject myCanvas;
void Start(){
Instantiate(mycanvas);
}