コード例 #1
0
ファイル: SceneRef.cs プロジェクト: polycular/oekogotschi
 /// <summary>
 /// Resolves this SceneRef to a Scene, caching and reruning the result
 /// </summary>
 /// <returns></returns>
 public Scene resolve()
 {
     if (mIsInvalid)
         return null;
     if(mPath.Length == 0)
     {
         mIsInvalid = true;
         return null;
     }
     if (mResolvedScene == null)
     {
         mResolvedScene = SceneManager.Instance.getSceneByPath(mPath);
         if (mResolvedScene == null)
             mIsInvalid = true;
     }
     return mResolvedScene;
 }
コード例 #2
0
ファイル: SceneManager.cs プロジェクト: polycular/oekogotschi
        /// <summary>
        /// Creates a new SceneManager and serializes it directly.
        /// </summary>
        /// <param name="scenes">A List of Scenes. The Scenes path has to be relative to the Assets/ directory</param>
        /// <param name="final">If true, the serilization will try to minimize the serialized file</param>
        static public void saveToStreamingAssets(Scene[] scenes, bool final)
        {
            SceneManager manager = new SceneManager();

            foreach (Scene scene in scenes)
            {
                manager.mScenes.Add(scene.Path, scene);
            }

            Directory.CreateDirectory(Path.GetDirectoryName(getFilePath()));
            string json = JsonConvert.SerializeObject(manager, ((final)?Formatting.None : Formatting.Indented));
            File.WriteAllText(getFilePath(), json);
        }
コード例 #3
0
ファイル: SceneManager.cs プロジェクト: polycular/oekogotschi
 private void emitAfterSceneChangeEvent(Scene oldScene, Scene newScene)
 {
     if (afterSceneChange != null)
     {
         afterSceneChange(oldScene, newScene);
     }
     if (mCurrentScene != null)
         mCurrentScene.emitAfterSceneChangeToEvent(oldScene, newScene);
 }
コード例 #4
0
ファイル: SceneManager.cs プロジェクト: polycular/oekogotschi
 private void emitBeforeSceneChangeEvent(Scene oldScene, Scene newScene)
 {
     if (mCurrentScene != null)
         mCurrentScene.emitBeforeSceneLeaveEvent(oldScene, newScene);
     if (newScene != null)
         newScene.emitBeforeSceneChangeToEvent(oldScene, newScene);
     if (beforeSceneChange != null)
     {
         beforeSceneChange(oldScene, newScene);
     }
 }
コード例 #5
0
ファイル: SceneManager.cs プロジェクト: polycular/oekogotschi
        public Scene changeScene(Scene target)
        {
            if (target == null)
            {
                Debug.LogError("Could not changeScene, as no Scene was found (sene was null)");
                return null;
            }

            Scene oldScene = mCurrentScene;
            emitBeforeSceneChangeEvent(oldScene, target);
            mCurrentScene = target;
            Application.LoadLevel(target.Index);
            emitAfterSceneChangeEvent(oldScene, target);
            return mCurrentScene;
        }
コード例 #6
0
ファイル: SceneRef.cs プロジェクト: polycular/oekogotschi
        public static SceneRef fromScene(Scene scene)
        {
            if (scene == null)
                return null;
            SceneRef sceneref = new SceneRef();
            sceneref.mPath = scene.Path;
            sceneref.mResolvedScene = scene;

            return sceneref;
        }
コード例 #7
0
ファイル: Scene.cs プロジェクト: polycular/oekogotschi
 public void emitBeforeSceneChangeToEvent(Scene oldScene, Scene newScene)
 {
     if (beforeSceneChangeTo != null)
     {
         beforeSceneChangeTo(oldScene, newScene);
     }
 }
コード例 #8
0
ファイル: Scene.cs プロジェクト: polycular/oekogotschi
 public void emitBeforeSceneLeaveEvent(Scene oldScene, Scene newScene)
 {
     if (beforeLeave != null)
     {
         beforeLeave(oldScene, newScene);
     }
 }
コード例 #9
0
ファイル: Scene.cs プロジェクト: polycular/oekogotschi
        static public Scene[] fetchAllFromBuildSettings()
        {
            List<Scene> scenes = new List<Scene>();
            int i = 0;
            //Walk through the build settings again to get the index of this
            foreach (var buildSetting in UnityEditor.EditorBuildSettings.scenes)
            {
                if (buildSetting.enabled)
                {
                    Scene scene = new Scene();
                    scene.mIdx = i;

                    scene.mPath = PathExtensions.getRelativePathTo(System.IO.Path.GetFullPath(buildSetting.path), Application.dataPath+"/");

                    scene.mGUID = UnityEditor.AssetDatabase.AssetPathToGUID(buildSetting.path);
                    i++;
                    scenes.Add(scene);
                }
            }
            return scenes.ToArray();
        }
コード例 #10
0
ファイル: Scene.cs プロジェクト: polycular/oekogotschi
 public void emitAfterSceneChangeToEvent(Scene oldScene, Scene newScene)
 {
     if (afterSceneChangeTo != null)
     {
         afterSceneChangeTo(oldScene, newScene);
     }
 }