Question by
Mad_Mark · Jan 02, 2021 at 04:12 PM ·
asynchronous
Check if async scene is loaded
I am loading a primary 256 unit scene at the center, and one scene 256 units in each direction to form a grid of 9 scenes using asynchronous additive scene loading from a menu screen. My character exists in the main scene and has DontDestroy instance code for persistence.
What I would like to accomplish, is if a particular scene (Trapper_0) is loaded, enable the player object. If it is NOT enabled, the player will just fall through where the ground should be, so disable the player.
My latest attempt is: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;
public class WaitForSceneLoaded : MonoBehaviour
{
private Transform playerTransform;
void Start()
{
playerTransform = transform;
playerTransform.gameObject.SetActive(false);
}
void Update()
{
if(SceneManager.GetSceneByName("Mississauga-Trapper 0").IsValid())
{
Debug.Log("Got here");
playerTransform.gameObject.SetActive(true);
//sceneDone = true;
this.enabled = false;
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613022540im_/https://answers.unity.com/themes/thub/images/avi.jpg)