I don’t understand why the scene does not change.
Any idea please?
using UnityEngine;
using System.Collections;
public class SplashSceneManager : MonoBehaviour {
public string NextSceneName;
public GameObject LoadingBarObject;
public float FinishBarScale;
AsyncOperation asyncOperation = null;
Transform loadingBarTransform = null;
// Use this for initialization
void Start () {
Invoke ("LoadNextScene", 1f);
loadingBarTransform = LoadingBarObject.transform;
}
// Update is called once per frame
void Update () {
if (asyncOperation != null) {
loadingBarTransform.localScale = new Vector3 (asyncOperation.progress * FinishBarScale, loadingBarTransform.localScale.y, loadingBarTransform.localScale.z);
}
}
public void LoadNextScene()
{
StartCoroutine("LoadingScene");
}
IEnumerator LoadingScene() {
Debug.LogWarning("ASYNC LOAD STARTED - " +"DO NOT EXIT PLAY MODE UNTIL SCENE LOADS... UNITY WILL CRASH");
asyncOperation = Application.LoadLevelAsync(NextSceneName);
asyncOperation.allowSceneActivation = false;
Debug.Log ("Finishsadsad");
yield return asyncOperation;
Invoke("ActivateScene",1f);
}
void ActivateScene()
{
asyncOperation.allowSceneActivation = false;
Debug.Log ("Change Scene");
}
}