Exemplo n.º 1
0
    public void SwitchToLevel(SceneId sceneId, Action <float> loadCallback = null)
    {
        if (sceneId == _cur_scene_id)
        {
            Debug.LogError("已经在该场景 " + sceneId.ToString());
        }
        _cur_scene_id = sceneId;

        AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(sceneId.ToString());

        load_timer_id = TimerManager.Instance().RepeatCallFunc(delegate(float dt) {
            if (asyncLoad.isDone)
            {
                TimerManager.Instance().DestroyTimer(load_timer_id);
                load_timer_id = -1;
                if (loadCallback != null)
                {
                    loadCallback.Invoke(100f);
                }
            }
            else
            {
                if (loadCallback != null)
                {
                    loadCallback.Invoke(asyncLoad.progress);
                }
            }
        }, 0.01f);
    }
    public void SwitchToScene(SceneId sceneId, object param = null)
    {
        if (sceneId == CurrentSceneId)
        {
            LogModule.WarningLog("switch to current scene: " + sceneId);
        }
        LogModule.DebugLog("SceneMgr  SwitchToScene  sceneId:" + sceneId.ToString() + "  " + System.DateTime.Now.ToString());
        mParam = param;

        if (mCurScene != null)
        {
            mCurScene.OnWillExit();
            //App.EventMgr.Post(EventId.SceneWillExit, mCurScene.Id);
        }

        if (mSceneTypeDict.ContainsKey(sceneId))
        {
            mNextScene = Activator.CreateInstance(mSceneTypeDict[sceneId]) as SceneBase;
            if (mNextScene != null)
            {
                mNextScene.OnWillEnter(param);
            }
        }

        if (hdlSceneWillSwitch != null)
        {
            hdlSceneWillSwitch.Invoke(mCurrentSceneId, sceneId, param);
        }

        SceneManager.LoadScene(sceneId.ToString());
    }
Exemplo n.º 3
0
        public void AddPlat()
        {
            if (++_iPlatIndex > BattleManager.GetInst().Stairs)
            {
                return;
            }

            BattleFieldData field = BattleManager.GetInst().GetFieldData(_iPlatIndex);
            BattlePlat      plat  = ResourceMgr.PopBox(SceneId, field.Type);

            plat.Index = _iPlatIndex;
            plat.X     = field.X;
            plat.Y     = field.Y;
            plat.m_Transform.SetParent(ForegroundTran);
            plat.m_Transform.localPosition = new Vector3(field.X, field.Y, 0f);
            plat.m_Transform.localScale    = Vector3.one;
            if (field.Item > 0)
            {
                string itemId = ConfigData.GetValue("Scene_Common", SceneId.ToString(), string.Format("Item{0}", field.Item));
                if (itemId != "-1")
                {
                    int        id   = int.Parse(itemId);
                    BattleItem item = ResourceMgr.PopItem(id);
                    item.Type = id;
                    item.m_Transform.SetParent(plat.m_Transform, false);
                }
            }
            _dicPlat.Add(_iPlatIndex, plat);
        }
Exemplo n.º 4
0
        /// <summary>
        /// シーンIDを追加するGUIを表示する
        /// </summary>
        void ShowHeader()
        {
            using (new EditorGUILayout.HorizontalScope())
            {
                // GUI:シーンIDの列挙体
                _selectSceId = (SceneId)EditorGUILayout.EnumPopup(
                    "Add scene", _selectSceId);
                string sceName = _selectSceId.ToString();

                // GUI:追加ボタン
                if (GUILayout.Button("+", EditorStyles.miniButtonRight, GUILayout.Width(20)))
                {
                    _selectSceId = 0;

                    // ビルド設定を再取得
                    _scenes.Clear();
                    foreach (var obj in EditorBuildSettings.scenes)
                    {
                        if (obj.enabled)
                        {
                            _scenes.Add(Path.GetFileNameWithoutExtension(obj.path), obj);
                        }
                    }

                    // シーンがビルド設定に存在しないか無効の場合
                    if (!_scenes.ContainsKey(sceName))
                    {
                        Log.Warning("シーン({0})がビルド設定に存在しないか無効です", sceName);
                        return;
                    }

                    EditorBuildSettingsScene scene = _scenes[sceName];

                    // シーンが読み込まれていない場合
                    Scene loaded = EditorSceneManager.GetSceneByName(sceName);
                    if (loaded.isLoaded)
                    {
                        return;
                    }

                    // 追加モードでシーンをロードする
                    UnityEditor.SceneManagement.EditorSceneManager
                    .OpenScene(scene.path, OpenSceneMode.Additive);
                    _sceNames.Add(sceName);
                }
            }
        }
Exemplo n.º 5
0
 protected GameScene(SceneId sceneId, ICamera camera, IList <Type> activeActiveRendererTypes)
     : base(sceneId.ToString(), camera, activeActiveRendererTypes)
 {
     Id = sceneId;
 }
Exemplo n.º 6
0
 public static void Load(SceneId sceneId)
 {
     SceneManager.LoadScene(sceneId.ToString());
 }
Exemplo n.º 7
0
 /// <summary>
 /// ISceneLoaderを参照
 /// </summary>
 /// /// <param name="sceId"></param>
 public void UnloadScene(SceneId sceId)
 {
     UnloadScene(sceId.ToString());
 }
Exemplo n.º 8
0
 /// <summary>
 /// ISceneLoaderを参照
 /// </summary>
 /// <param name="sceId"></param>
 public void LoadScene(SceneId sceId)
 {
     LoadScene(sceId.ToString());
 }
Exemplo n.º 9
0
 protected GameScene(SceneId sceneId, ICamera camera)
     : base(sceneId.ToString(), camera)
 {
     Id = sceneId;
 }
Exemplo n.º 10
0
 public static void LoadScene(this SceneManager scene, SceneId sceneId)
 {
     scene.LoadScene(sceneId.ToString());
 }
Exemplo n.º 11
0
 /// <summary>
 /// シーンを遷移する
 /// </summary>
 /// <param name="sceId">シーンID</param>
 public void TransitionScene(SceneId sceId)
 {
     TransitionScene(sceId.ToString());
 }