- Home /
How would I load a Canvas from another scene?
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?
Answer by efeguclu · Jul 11, 2017 at 02:07 PM
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);
}
Thank you,
It works but how can I resize the added canvas? it has shown as a full screen of my scene
Answer by Taylor-Libonati · Mar 21, 2019 at 05:10 PM
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: https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadSceneAsync.html Afterwords you can find the object multiple ways but the main one being the Find method: https://docs.unity3d.com/ScriptReference/GameObject.Find.html
Answer by Ted-Bigham · Apr 30, 2020 at 03:09 PM
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.
Your answer
![](https://koobas.hobune.stream/wayback/20220612130004im_/https://answers.unity.com/themes/thub/images/avi.jpg)