Exemple #1
0
    /// <summary>
    /// 読込開始
    /// </summary>
    /// <param name="id"></param>
    /// <param name="addtive"></param>
    /// <param name="async"></param>
    public SceneLoader(SceneDefine.SCENE_ID id, bool addtive, bool async)
    {
        SceneID      = id;
        Name         = SceneDefine.SceneNames[(int)id];
        this.addtive = addtive;
        this.async   = async;

        if (async)
        {
            var param = new UnityEngine.SceneManagement.LoadSceneParameters();
            if (addtive)
            {
                param.loadSceneMode = UnityEngine.SceneManagement.LoadSceneMode.Additive;
            }
            else
            {
                param.loadSceneMode = UnityEngine.SceneManagement.LoadSceneMode.Single;
            }

            asyncOperation = UnitySceneManager.LoadSceneAsync(Name, param);
        }
        else
        {
            if (addtive)
            {
                UnitySceneManager.LoadScene(Name, UnityEngine.SceneManagement.LoadSceneMode.Additive);
            }
            else
            {
                UnitySceneManager.LoadScene(Name, UnityEngine.SceneManagement.LoadSceneMode.Single);
            }
        }
    }
Exemple #2
0
    /// <summary>
    /// セットアップ(読込完了)
    /// </summary>
    /// <param name="id"></param>
    public void Setup(SceneDefine.SCENE_ID id, UnityScene unityScene)
    {
        SceneID    = id;
        UnityScene = unityScene;

        Loaded();
    }
Exemple #3
0
    private void Update()
    {
        for (int i = 0; i < sceneLoaderList.Count; i++)
        {
            SceneLoader loader = sceneLoaderList[i];
            bool        loaded = loader.Update();
            if (loaded)
            {
                SceneDefine.SCENE_ID id         = loader.SceneID;
                UnityScene           unityScene = UnitySceneManager.GetSceneByName(loader.Name);
                SceneBase            scene      = GameObject.Find(unityScene.name).GetComponent <SceneBase>();
                sceneList.Add(scene);

                sceneLoaderList.RemoveAt(i);

                UnitySceneManager.SetActiveScene(unityScene);
                scene.Setup(id, unityScene);
                break;
            }
        }

        for (int i = 0; i < sceneList.Count; i++)
        {
            // アンロード処理
            if (sceneList[i] == null)
            {
                sceneList.RemoveAt(i);
                break;
            }
        }
    }
Exemple #4
0
    /// <summary>
    /// シーンをアクティブする。
    /// </summary>
    /// <param name="id"></param>
    public static void SetActiveScene(SceneDefine.SCENE_ID id)
    {
        List <SceneBase> sceneList = Instance.sceneList;

        for (int i = 0; i < sceneList.Count; i++)
        {
            if (sceneList[i].SceneID == id)
            {
                UnitySceneManager.SetActiveScene(sceneList[i].UnityScene);
                break;
            }
        }
    }
Exemple #5
0
    /// <summary>
    /// シーンを破棄する
    /// </summary>
    public static void UnloadScene(SceneDefine.SCENE_ID id)
    {
        List <SceneBase> sceneList = Instance.sceneList;

        for (int i = 0; i < sceneList.Count; i++)
        {
            if (sceneList[i].SceneID == id)
            {
                sceneList[i].StartUnload();
                UnitySceneManager.UnloadSceneAsync(sceneList[i].UnityScene.name);
                break;
            }
        }
    }
Exemple #6
0
    /// <summary>
    /// 読込終了したか?
    /// </summary>
    /// <returns></returns>
    public static bool IsLoaded(SceneDefine.SCENE_ID id)
    {
        List <SceneLoader> loaderList = Instance.sceneLoaderList;

        for (int i = 0; i < loaderList.Count; i++)
        {
            if (loaderList[i].SceneID == id)
            {
                return(true);
            }
        }

        return(false);
    }
Exemple #7
0
 /// <summary>
 /// シーンをロードする。
 /// </summary>
 public static void LoadScene(SceneDefine.SCENE_ID id, bool async = true, bool addtive = false)
 {
     Instance.sceneLoaderList.Add(new SceneLoader(id, addtive, async));
 }