private static BuildPlayerOptions GetBuildOptions(Scene scene)
 {
     BuildPlayerOptions options = new BuildPlayerOptions();
     options.scenes = new string[] { scene.path };
     options.options |= BuildOptions.AutoRunPlayer | BuildOptions.Development;
     options.target = EditorUserBuildSettings.activeBuildTarget;
     string str = Path.Combine(Path.Combine(FileUtil.GetUniqueTempPathInProject(), "TestRun"), "test." + PostprocessBuildPlayer.GetExtensionForBuildTarget(options.target, options.options));
     options.locationPathName = str;
     return options;
 }
 private void BuildAndRunPlayer(Scene scene)
 {
     string str = BuildPipeline.BuildPlayer(GetBuildOptions(scene));
     if (!string.IsNullOrEmpty(str))
     {
         Debug.LogError(str);
     }
 }
        void Start()
        {
            if (sceneToLoad < 0)
                return;

            this.fadeOverlay.gameObject.SetActive(true); // Making sure it's on so that we can crossfade Alpha
            this.currentScene = SceneManager.GetActiveScene();
            this.StartCoroutine(this.LoadAsync(sceneToLoad));
        }
Esempio n. 4
0
 public static Scene[] GetAllScenes()
 {
     Scene[] sceneArray = new Scene[sceneCount];
     for (int i = 0; i < sceneCount; i++)
     {
         sceneArray[i] = GetSceneAt(i);
     }
     return sceneArray;
 }
Esempio n. 5
0
        int GetSceneIndex(Scene scene)
        {
            for (int i = 0; i < SceneManager.sceneCount; i++)
            {
                if (SceneManager.GetSceneAt(i) == scene)
                {
                    return i;
                }
            }

            throw Assert.CreateException();
        }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.SceneManagement.Scene o;
			o=new UnityEngine.SceneManagement.Scene();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
		/// <summary>
		/// Return the Singleton for a given scene (there is one per Scene).
		/// </summary>
		/// <param name="scene">The Scene to obtain the singleton for</param>
		/// <returns>The per-scene singleton</returns>
		public static AmsCrossSceneReferences	GetSceneSingleton( Scene scene, bool bCreateIfNotFound )
		{
			var multiSceneSetup = GameObjectEx.GetSceneSingleton<AmsMultiSceneSetup>( scene, bCreateIfNotFound );
			if ( !multiSceneSetup )
				return null;

			var existing = multiSceneSetup.gameObject.GetComponent<AmsCrossSceneReferences>();
			if ( existing )
				return existing;
			else if ( bCreateIfNotFound )
				return multiSceneSetup.gameObject.AddComponent<AmsCrossSceneReferences>();

			return null;
		}
		private static void OnHierarchyChange () 
		{
#if UNITY_5_3
            Scene currentSceneName = EditorSceneManager.GetActiveScene ();
#else
		    string currentSceneName = Application.loadedLevelName;
#endif
            if (loadedScene != currentSceneName)
			{
				if (justOpenedNewScene != null)
					justOpenedNewScene.Invoke ();
				loadedScene = currentSceneName;
			}
		}
Esempio n. 9
0
        private void HideNoUndo(Scene scene)
        {
            if (!scene.IsValid())
            {
                return;
            }

            if (!scene.isLoaded)
            {
                return;
            }

            SceneVisibilityState.ShowScene(scene);
            scene.GetRootGameObjects(m_RootBuffer);
            SceneVisibilityState.SetGameObjectsHidden(m_RootBuffer.ToArray(), true, true);
        }
 public static int GetSceneByBuildIndex_wrap(long L)
 {
     try
     {
         long VM   = FCLibHelper.fc_get_vm_ptr(L);
         int  arg0 = FCLibHelper.fc_get_int(L, 0);
         UnityEngine.SceneManagement.Scene ret = UnityEngine.SceneManagement.SceneManager.GetSceneByBuildIndex(arg0);
         long ret_ptr = FCLibHelper.fc_get_return_ptr(L);
         long v       = FCGetObj.PushObj(ret);
         FCLibHelper.fc_set_value_wrap_objptr(VM, ret_ptr, v);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
Esempio n. 11
0
 private static void EditorSceneManagerOnSceneOpened(Scene scene, OpenSceneMode mode)
 {
     if (mode == OpenSceneMode.Single)
     {
         SceneVisibilityState.isolation = false;
     }
     if (mode == OpenSceneMode.Additive)
     {
         //make sure added scenes are isolated when opened if main stage is isolated
         if (!StageNavigationManager.instance.currentItem.isPrefabStage)
         {
             Undo.ClearUndo(SceneVisibilityState.GetInstance());
         }
     }
     instance.VisibilityChanged();
     instance.PickableContentChanged();
 }
Esempio n. 12
0
 public void OnProcessScene(UnityEngine.SceneManagement.Scene scene)
 {
     if (!sawManager)
     {
         if (scene.isLoaded)
         {
             foreach (var gameObject in scene.GetRootGameObjects())
             {
                 if (gameObject.GetComponentInChildren <PolyToolkitManager>() != null)
                 {
                     sawManager = true;
                     break;
                 }
             }
         }
     }
 }
Esempio n. 13
0
    public void OnGUI()
    {
        UnityEngine.SceneManagement.Scene sc = SceneManager.GetSceneByName("ExampleMenu");
        if (sc.IsValid())
        {
            GUI.BeginGroup(new Rect(Screen.width - 150, Screen.height - 40, 300, 400));
            GUILayout.BeginVertical("box", GUILayout.Width(150));

            if (GUILayout.Button("Back"))
            {
                SceneManager.LoadScene(0);
            }

            GUILayout.EndVertical();
            GUI.EndGroup();
        }
    }
 public static int UnloadSceneAsync2_wrap(long L)
 {
     try
     {
         long VM = FCLibHelper.fc_get_vm_ptr(L);
         UnityEngine.SceneManagement.Scene arg0 = FCGetObj.GetObj <UnityEngine.SceneManagement.Scene>(FCLibHelper.fc_get_wrap_objptr(L, 0));
         UnityEngine.AsyncOperation        ret  = UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync(arg0);
         long ret_ptr = FCLibHelper.fc_get_return_ptr(L);
         long v       = FCGetObj.PushObj(ret);
         FCLibHelper.fc_set_value_wrap_objptr(VM, ret_ptr, v);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
 public static int CreateScene_wrap(long L)
 {
     try
     {
         long   VM   = FCLibHelper.fc_get_vm_ptr(L);
         string arg0 = FCLibHelper.fc_get_string_a(L, 0);
         UnityEngine.SceneManagement.Scene ret = UnityEngine.SceneManagement.SceneManager.CreateScene(arg0);
         long ret_ptr = FCLibHelper.fc_get_return_ptr(L);
         long v       = FCGetObj.PushObj(ret);
         FCLibHelper.fc_set_value_wrap_objptr(VM, ret_ptr, v);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
Esempio n. 16
0
 public static int Equals_wrap(long L)
 {
     try
     {
         long nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L);
         UnityEngine.SceneManagement.Scene obj = get_obj(nThisPtr);
         System.Object arg0    = FCGetObj.GetSystemObj(FCLibHelper.fc_get_param_ptr(L, 0));
         bool          ret     = obj.Equals(arg0);
         long          ret_ptr = FCLibHelper.fc_get_return_ptr(L);
         FCLibHelper.fc_set_value_bool(ret_ptr, ret);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
Esempio n. 17
0
    void OnSceneLoaded(UnityEngine.SceneManagement.Scene scene, UnityEngine.SceneManagement.LoadSceneMode mode)
    {
        if (SceneManager.GetActiveScene().buildIndex == 0)
        {
            /*if (mobile == null) {
             *      mobile = GameObject.FindGameObjectWithTag ("MobileController");
             * }
             * mobile.SetActive (false);*/

            //Destroy (gameObject);
            GameObject[] allObjects = GameObject.FindGameObjectsWithTag("SceneChanger");
            foreach (GameObject obj in allObjects)
            {
                Destroy(obj);
            }
        }
    }
Esempio n. 18
0
        public Scene()
        {
            components.Add(new Octree());
            components.Add(new DebugRenderer());
            components.Add(new Zone());
            components.Add(new Skybox());

            List <GameObject> rootObjects = new List <GameObject>();

            UnityEngine.SceneManagement.Scene scene = SceneManager.GetActiveScene();
            scene.GetRootGameObjects(rootObjects);

            foreach (GameObject node in rootObjects)
            {
                nodes.Add(new Node(node));
            }
        }
Esempio n. 19
0
        /**
         * Call this when the player crosses the bounds into another scene so adjacent scenes are loaded.
         */
        public static void SceneTransitionMade(int x, int y)
        {
            string name = SceneMap.GetPartition(x, y);

            if (activeScene.Equals(name) || name == null)
            {
                return;
            }
            activeSceneX = x;
            activeSceneY = y;
            activeScene  = name;
            UnityEngine.SceneManagement.Scene scene = SceneManager.GetSceneByName(name);
            UnloadScenes();
            LoadAdjacentScenes();
            SceneManager.SetActiveScene(SceneManager.GetSceneByName(name));
            //printSceneInfo();
        }
Esempio n. 20
0
 public static int GetHashCode_wrap(long L)
 {
     try
     {
         long VM       = FCLibHelper.fc_get_vm_ptr(L);
         long nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L);
         UnityEngine.SceneManagement.Scene obj = get_obj(nThisPtr);
         int  ret     = obj.GetHashCode();
         long ret_ptr = FCLibHelper.fc_get_return_ptr(L);
         FCLibHelper.fc_set_value_int(ret_ptr, ret);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
Esempio n. 21
0
 bool GetSceneSetState(string sceneName, bool activity)
 {
     UnityEngine.SceneManagement.Scene scene = UnityEngine.SceneManagement.SceneManager.GetSceneByName(sceneName);
     if (scene != null && scene.IsValid() && scene.isLoaded)
     {
         GameObject[] objs = scene.GetRootGameObjects();
         if (objs != null)
         {
             foreach (var obj in objs)
             {
                 obj.SetActive(activity);
             }
         }
         return(true);
     }
     return(false);
 }
Esempio n. 22
0
 public static int GetRootGameObjects_wrap(long L)
 {
     try
     {
         long VM       = FCLibHelper.fc_get_vm_ptr(L);
         long nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L);
         UnityEngine.SceneManagement.Scene obj = get_obj(nThisPtr);
         UnityEngine.GameObject[]          ret = obj.GetRootGameObjects();
         long ret_ptr = FCLibHelper.fc_get_return_ptr(L);
         FCCustomParam.ReturnArray(VM, ret, ret_ptr);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
Esempio n. 23
0
 public static int GetRootGameObjects1_wrap(long L)
 {
     try
     {
         long VM       = FCLibHelper.fc_get_vm_ptr(L);
         long nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L);
         UnityEngine.SceneManagement.Scene obj  = get_obj(nThisPtr);
         List <UnityEngine.GameObject>     arg0 = null;
         arg0 = FCCustomParam.GetList(ref arg0, L, 0);
         obj.GetRootGameObjects(arg0);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
Esempio n. 24
0
 /// <summary>
 /// Sets the active scene. When using Load or LoadAsync, newly loaded scene will automatically be set to active if scene was not loaded additive.
 /// </summary>
 /// <param name="sceneName">Scene name.</param>
 public void SetActiveScene(string sceneID)
 {
     UnityEngine.SceneManagement.Scene scene = SceneManager.GetSceneByName(sceneID);
     if (scene.isLoaded == true)
     {
         //Activate scene
         ActivateScene(sceneID);
         //Set as active scene
         SceneManager.SetActiveScene(scene);
         //Fire signal trigger
         //_sceneSetAsActiveSignalTrigger.Fire(sceneName);
         _eventService.Publish(new Events.SceneSetAsActiveEvent {
             sceneID = sceneID
         });
         Debug.Log("Setting " + scene.name + " as active scene");
     }
 }
        static void SaveAll()
        {
            UnityEngine.SceneManagement.Scene sc = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
            if (!sc.IsValid())
            {
                return;
            }

            SceneConfig data = new SceneConfig();

            data.Data.LevelName = sc.name;

            GameObject[] array = GameObject.FindGameObjectsWithTag(SERIALIZE_SCENE_OBJECT_TAG);
            if (array == null)
            {
                return;
            }

            for (int i = 0; i < array.Length; ++i)
            {
                UnityEngine.Object parentObject = PrefabUtility.GetPrefabParent(array[i]);
                string             path         = AssetDatabase.GetAssetPath(parentObject);
                if (string.IsNullOrEmpty(path))
                {
                    continue;
                }

                var transform = array[i].transform;
                var parent    = transform.parent;

                //写入数据
                var obj = new SceneConfigData.SceneObject();
                obj.AssetName  = path;
                obj.Position   = transform.position;
                obj.Scale      = transform.lossyScale;
                obj.Rotation   = transform.rotation;
                obj.ParentName = parent != null?
                                 Common.CalcTransformHierarchyPath(parent) : "";

                data.Data.SceneObjects.Add(obj);
            }

            data.Save(SceneConfig.GetSceneConfigPath(sc.path));
            AssetDatabase.Refresh();
        }
Esempio n. 26
0
    private void SceneManager_sceneLoaded(UnityEngine.SceneManagement.Scene _scene, LoadSceneMode _mode)
    {
        if (_scene.name == "UIScene")
        {
            return;
        }
        SceneManager.SetActiveScene(_scene);
        if (!m_activeObjectsByScene.ContainsKey(_scene.path))
        {
            // First Load, activate only initial objects
            List <string>     activeObjects = new List <string>();
            ClickableObject[] allObjects    = FindObjectsOfType <ClickableObject>();

            foreach (ClickableObject obj in allObjects)
            {
                if (obj.m_InitalActive)
                {
                    activeObjects.Add(obj.m_ObjectName + obj.name);
                    obj.gameObject.SetActive(true);
                }
                else
                {
                    obj.gameObject.SetActive(false);
                }
            }
            m_activeObjectsByScene.Add(_scene.path, activeObjects);
        }
        else
        {
            // reload
            ClickableObject[] allObjects    = FindObjectsOfType <ClickableObject>();
            List <string>     activeObjects = m_activeObjectsByScene[_scene.path];
            foreach (ClickableObject obj in allObjects)
            {
                if (activeObjects.Contains(obj.m_ObjectName + obj.name))
                {
                    obj.gameObject.SetActive(true);
                }
                else
                {
                    obj.gameObject.SetActive(false);
                }
            }
        }
    }
Esempio n. 27
0
        static void OnLevelFinishedLoading(sm.Scene scene, sm.LoadSceneMode mode)
        {
            // Stuff to do when scene has finished loading

            if (current.scenes[scene.buildIndex].gameScene)
            {
                CoreManager.current.inGame = true;
                CoreManager.current.player = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
            }
            else
            {
                CoreManager.current.inGame = false;
            }

            CoreManager.UpdatePresence();

            sm.SceneManager.sceneLoaded -= OnLevelFinishedLoading;
        }
Esempio n. 28
0
        static public T[] SearchScene <T>(UnityEngine.SceneManagement.Scene scene, bool searchInActiveGameObjects) where T : Component
        {
            if (!scene.isLoaded)
            {
                return(null);
            }

            var gos = scene.GetRootGameObjects();

            var list = new FastList <T>();

            foreach (var go in gos)
            {
                list.AddRange(SearchParent <T>(go, searchInActiveGameObjects));
            }

            return(list.ToArray());
        }
Esempio n. 29
0
    static private void ProcOnSceneLoaded(UnityEngine.SceneManagement.Scene arg0, UnityEngine.SceneManagement.LoadSceneMode arg1)
    {
        if (CManagerUILocalize.instance != null)
        {
            CManagerUILocalize.instance.DoSetLocalize_CurrentScene();
        }

        p_pManagerScene.EventCheckIsLoadComplete();

        instance.OnSceneLoaded(arg0, arg1);
        if (_OnFinishLoad_Scene != null && _strCallBackRequest_SceneName != null && _strCallBackRequest_SceneName.CompareTo(arg0.name) == 0)
        {
            _strCallBackRequest_SceneName = "";
            System.Action OnFinishCurrentScene = _OnFinishLoad_Scene;
            _OnFinishLoad_Scene = null;
            OnFinishCurrentScene();
        }
    }
Esempio n. 30
0
 void OnSceneLoaded(UnityEngine.SceneManagement.Scene scene, UnityEngine.SceneManagement.LoadSceneMode mode)
 {
     //if (scene.name == "StoryScene")
     //{
     //    bgm.volume -= Time.deltaTime;
     //    Destroy(gameObject);
     //    //Debug.Log("I am inside the if statement");
     //}
     if (bgm != null)
     {
         if (scene.name == "StoryScene")
         {
             bgm.volume -= Time.deltaTime;
             Destroy(gameObject);
             //Debug.Log("I am inside the if statement");
         }
     }
 }
Esempio n. 31
0
        protected override void OnDrawForm(int id)
        {
            m_ScrollPos = GUILayout.BeginScrollView(m_ScrollPos);
            {
                Label(GetString("Scene Count"), SceneManager.sceneCount.ToString());
                Label(GetString("Scene Count In Build Settings"), SceneManager.sceneCountInBuildSettings.ToString());

                UnityEngine.SceneManagement.Scene activeScene = SceneManager.GetActiveScene();
                Label(GetString("Active Scene Name"), activeScene.name);
                Label(GetString("Active Scene Path"), activeScene.path);
                Label(GetString("Active Scene Build Index"), activeScene.buildIndex.ToString());
                Label(GetString("Active Scene Is Dirty"), activeScene.isDirty.ToString());
                Label(GetString("Active Scene Is Loaded"), activeScene.isLoaded.ToString());
                Label(GetString("Active Scene Is Valid"), activeScene.IsValid().ToString());
                Label(GetString("Active Scene Root Count"), activeScene.rootCount.ToString());
            }
            GUILayout.EndScrollView();
        }
        public bool AreAllDescendantsHidden(Scene scene)
        {
            if (scene.rootCount == 0)
            {
                return(false);
            }

            scene.GetRootGameObjects(m_RootBuffer);
            foreach (GameObject root in m_RootBuffer)
            {
                if (!SceneVisibilityState.IsHierarchyHidden(root))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 33
0
 private void SceneManager_sceneLoaded(UnityEngine.SceneManagement.Scene arg0, LoadSceneMode arg1)
 {
     if (arg0.name == this._sceneName)
     {
         SceneManager.sceneLoaded -= this.SceneManager_sceneLoaded;
         if (arg0.rootCount == 1)
         {
             this._loadedSceneRoot = arg0.GetRootGameObjects()[0];
         }
         else
         {
             Debug.Log("More than one root object in cave scene: " + this._sceneName);
             this._loadedSceneRoot = (string.IsNullOrEmpty(this._sceneObjectName) ? GameObject.FindWithTag(this._sceneObjectTag) : GameObject.Find(this._sceneObjectName));
         }
         this._onFinishedLoading.Invoke();
         this.OnActionFinished();
     }
 }
Esempio n. 34
0
 private void SceneManager_sceneLoaded(UnityEngine.SceneManagement.Scene arg0, LoadSceneMode arg1)
 {
     if (arg0.name == this.SceneName)
     {
         SceneManager.sceneLoaded -= this.SceneManager_sceneLoaded;
         if (arg0.rootCount == 1)
         {
             this.LoadedCaveGo = arg0.GetRootGameObjects()[0];
         }
         else
         {
             Debug.Log("More than one root object in cave scene: " + this.SceneName);
             this.LoadedCaveGo = GameObject.Find(this.RootName);
         }
         this.Loading = false;
         this.Async   = null;
     }
 }
Esempio n. 35
0
    /// <summary>
    /// Save Configuration of a single datamanager
    /// </summary>
    static void SaveDataManagerConfiguration()
    {
        // Add send data option here
        string currentPath = SceneManager.GetActiveScene().path;

        ConfigurationManager.manager.appId                 = ConfigurationManager.appId;
        ConfigurationManager.manager.appToken              = ConfigurationManager.appToken;
        ConfigurationManager.manager.testMode              = ConfigurationManager.testMode;
        ConfigurationManager.manager.pauseSendFlag         = ConfigurationManager.pauseSendFlag;
        ConfigurationManager.manager.periodicSendFlag      = ConfigurationManager.periodicSendFlag;
        ConfigurationManager.manager.pauseOnHeadsetRemoval = ConfigurationManager.pauseOnHeadsetRemoval;
        AddEventScripts(ConfigurationManager.manager.gameObject);
        EditorUtility.SetDirty(ConfigurationManager.manager); // Tells unity that it is modified and save it
        if (currentPath.Length > 0)
        {
            UnityEngine.SceneManagement.Scene scene = SceneManager.GetSceneByPath(currentPath);
            EditorSceneManager.SaveScene(scene);
        }
    }
Esempio n. 36
0
        private void Show(Scene scene, bool sendContentChangedEvent)
        {
            if (!scene.IsValid())
            {
                return;
            }

            if (!scene.isLoaded)
            {
                return;
            }

            SceneVisibilityState.ShowScene(scene);

            if (sendContentChangedEvent)
            {
                VisibilityChanged();
            }
        }
        static void RemoveAll()
        {
            UnityEngine.SceneManagement.Scene sc = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
            if (!sc.IsValid())
            {
                return;
            }

            GameObject[] array = GameObject.FindGameObjectsWithTag(SERIALIZE_SCENE_OBJECT_TAG);
            if (array == null)
            {
                return;
            }

            for (int i = 0; i < array.Length; ++i)
            {
                GameObject.DestroyImmediate(array[i]);
            }
        }
Esempio n. 38
0
        private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
        {
            try
            {
                var currentMap = GetCurrentMapNo();
                if (_lastLoadedMapNo == currentMap)
                {
                    return;
                }
                _lastLoadedMapNo = currentMap;

                StartCoroutine(MobManager.SpawnMobs(currentMap, arg0.name));
            }
            catch (Exception ex)
            {
                // Don't crash the event
                Logger.LogError(ex);
            }
        }
        internal static void LoadScenesForMerging()
		{
			Scene activeScene = new Scene();
			AmsMultiSceneSetup activeSetup = null;
			List<AmsMultiSceneSetup.SceneEntry> bakedScenes = new List<AmsMultiSceneSetup.SceneEntry>();

			GetCommonParameters( ref activeScene, ref activeSetup, bakedScenes );
			if ( bakedScenes.Count < 1 )
				return;

			AmsDebug.Log( null, "Running LoadScenesForBaking on Scene {0}", activeScene.name );

			// Now load all of the scenes
			foreach( var entry in bakedScenes )
			{
				var realScene = entry.scene.scene;
				if ( !realScene.IsValid() )
				{
					// This is good.  This means it's not loaded yet.
					realScene = EditorSceneManager.OpenScene( entry.scene.editorPath, OpenSceneMode.Additive );

					if ( !realScene.IsValid() )
					{
						AmsDebug.LogError( activeSetup, "BakeScene: Scene {0} ({1}) referenced from Multi-Scene Setup in {2} is invalid.", entry.scene.editorPath, entry.scene.name, activeScene.name );
						continue;
					}
				}

				// Let's catch this...
				if ( !realScene.isLoaded )
				{
					realScene = EditorSceneManager.OpenScene( realScene.path, OpenSceneMode.Additive );
					
					// if we're still not loaded, we're probably in trouble.
					if ( !realScene.isLoaded )
					{
						AmsDebug.LogError( activeSetup, "BakeScene: Scene {0} ({1}) referenced from Multi-Scene Setup in {2} could not load.", entry.scene.editorPath, entry.scene.name, activeScene.name );
						continue;
					}
				}
			}
		}
		private static void GetCommonParameters( ref Scene activeScene, ref AmsMultiSceneSetup activeSceneSetup, List<AmsMultiSceneSetup.SceneEntry> bakedScenes )
		{
			// We can only execute this when building the player.  Otherwise we expect entries to already be in the scene.
            if ( !BuildPipeline.isBuildingPlayer )
                return;

			// Get the SceneSetup for the Active Scene.
			activeScene = EditorSceneManager.GetActiveScene();
			activeSceneSetup = GameObjectEx.GetSceneSingleton<AmsMultiSceneSetup>( activeScene, false );
			if ( !activeSceneSetup )
				return;

			var scenesInSetup = activeSceneSetup.GetSceneSetup();
			foreach( var entry in scenesInSetup )
			{
                bool bShouldBake = entry.loadMethod == AmsMultiSceneSetup.LoadMethod.Baked;
				if ( bShouldBake )
					bakedScenes.Add( entry );
			}
		}
        void SelectContext(Scene scene)
        {
            var rootObjects = scene.GetRootGameObjects();
            var sceneContexts = rootObjects
                .SelectMany(x => x.GetComponentsInChildren<SceneContext>()).FirstOrDefault();

            if (sceneContexts != null)
            {
                Selection.activeGameObject = sceneContexts.gameObject;
            }
            else
            {
                var decoratorContexts = rootObjects
                    .SelectMany(x => x.GetComponentsInChildren<SceneDecoratorContext>()).FirstOrDefault();

                if (decoratorContexts != null)
                {
                    Selection.activeGameObject = decoratorContexts.gameObject;
                }
            }
        }
 public override void Run()
 {
     ConsoleWindow.SetConsoleErrorPause(false);
     Application.runInBackground = true;
     string sceneName = base.CreateSceneName();
     this.m_Scene = base.CreateBootstrapScene(sceneName, delegate (PlaymodeTestsController runner) {
         PlaymodeTestsControllerExtensions.AddEventHandlerMonoBehaviour<ResultsRenderer>(runner);
         PlaymodeTestsControllerExtensions.AddEventHandlerScriptableObject<WindowResultUpdater>(runner);
         PlaymodeTestsControllerExtensions.AddEventHandlerScriptableObject<TestRunnerCallback>(runner);
         if (this.m_Settings.isBatchModeRun)
         {
             PlaymodeTestsControllerExtensions.AddEventHandlerScriptableObject<PlaymodeResultSaverCallback>(runner);
             PlaymodeTestsControllerExtensions.AddEventHandlerScriptableObject<BatchRunCallback>(runner);
         }
         runner.settings = this.m_Settings;
     });
     if (this.m_Settings.sceneBased)
     {
         EditorBuildSettings.scenes = new List<EditorBuildSettingsScene> { new EditorBuildSettingsScene(sceneName, true) }.ToArray();
     }
     EditorApplication.update = (EditorApplication.CallbackFunction) Delegate.Combine(EditorApplication.update, new EditorApplication.CallbackFunction(this.UpdateCallback));
     this.m_InitPlaying = 3;
 }
 private static extern bool INTERNAL_CALL_MarkSceneDirty(ref Scene scene);
 public static extern bool SaveModifiedScenesIfUserWantsTo(Scene[] scenes);
Esempio n. 45
0
 public Map(Scene scene)
 {
     this.index = scene.buildIndex;
     this.name = scene.name;
     this.path = scene.path;
 }
		static void RestoreCrossSceneReferences()
		{
			Scene activeScene = new Scene();
			AmsMultiSceneSetup activeSetup = null;
			List<AmsMultiSceneSetup.SceneEntry> bakedScenes = new List<AmsMultiSceneSetup.SceneEntry>();

			GetCommonParameters( ref activeScene, ref activeSetup, bakedScenes );
			if ( bakedScenes.Count < 1 )
				return;

			AmsDebug.Log( null, "Running RestoreCrossSceneReferences on Scene {0}", activeScene.name );

			// Do the merge (bake)
			var targetCrossRefs = AmsCrossSceneReferences.GetSceneSingleton( activeScene, false );
			if ( targetCrossRefs )
				targetCrossRefs.ResolvePendingCrossSceneReferences();

			foreach( var entry in bakedScenes )
			{
				if ( !entry.scene.isLoaded )
				{
					AmsDebug.LogError( activeSetup, "Could not restore cross-scene references for non-loaded scene: {0}", entry.scene.name );
					continue;
				}

				var sourceCrossRefs = AmsCrossSceneReferences.GetSceneSingleton( entry.scene.scene, false );
				if ( sourceCrossRefs )
					sourceCrossRefs.ResolvePendingCrossSceneReferences();
			}
		}
		private void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode) {
			if (instance != this) {
				return;
			}

			if (androidUIResizeMode == AndroidUIResizeMode.ResizeCamera  || androidUIResizeMode == AndroidUIResizeMode.ResizeCameraAndReferenceResolution) {
				Camera.main.pixelRect = new Rect(0, 0, Screen.width, Screen.height - webViewHeight);
			}

			if (androidUIResizeMode == AndroidUIResizeMode.ResizeCameraAndReferenceResolution) {
				UnityEngine.UI.CanvasScaler[] allCanvasScalers = GameObject.FindObjectsOfType<UnityEngine.UI.CanvasScaler> ();
				
				for (int i = 0; i < allCanvasScalers.Length; ++i) {
					allCanvasScalers[i].referenceResolution = new Vector2 (allCanvasScalers[i].referenceResolution.x, allCanvasScalers[i].referenceResolution.y / (allCanvasScalers[i].referenceResolution.y - webViewHeight) * allCanvasScalers[i].referenceResolution.y);
				}
			}
		}
 private static extern bool INTERNAL_CALL_CloseScene(ref Scene scene, bool removeScene);
Esempio n. 49
0
File: Audio.cs Progetto: Ret44/SGJ16
    private void Initialize()
    {
        Audio._instance = this;

        UnityEngine.SceneManagement.Scene startScene = new UnityEngine.SceneManagement.Scene();
        int sceneCount = UnityEngine.SceneManagement.SceneManager.sceneCount;
        for(int i = 0;i < sceneCount;++i)
        {
            UnityEngine.SceneManagement.Scene tmpScene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i);

            if (tmpScene.name == GameLord.startSceneName)
            {
                startScene = tmpScene;
                break;
            }
        }

        _audioSourceObjectPool = new AudioSourceObjectPool(_transform, 24);
        int sourceCount = _audioSourceObjectPool.Size;
        AudioSource[] sources = _audioSourceObjectPool.Pool;
        //for(int i = 0;i < sourceCount;++i)
        //{
        //	UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(sources[i].gameObject, startScene);
        //}

        if (_music != null)
        {
            _musicSource = this.gameObject.AddComponent<AudioSource>();
            _musicSource.clip = _music;
            _musicSource.loop = true;
            _musicSource.Play();
            _musicSource.volume = 0.0f;
        }
    }
 public static extern bool SaveScenes(Scene[] scenes);
 private static extern void INTERNAL_CALL_NewScene(NewSceneSetup setup, NewSceneMode mode, out Scene value);
		/// <summary>
		/// Find the Scene of an object instance and use a cache to help look-ups.
		/// </summary>
		/// <param name="instance">The instance to look at</param>
		/// <param name="cache">The cache to populate</param>
		/// <returns>The scene instance belongs to</returns>
		private static Scene FindSceneCached( Object instance, Dictionary<Object, Scene> cache )
		{
			// Null SubScene
			if ( !instance )
				return new Scene();

			// Quick case, it's already cached...
			Scene scene = new Scene();
			if ( cache.TryGetValue(instance, out scene) )
				return scene;

			// Persistent objects are Assets
			if ( !EditorUtility.IsPersistent(instance) )
			{
                var gameObj = GameObjectEx.EditorGetGameObjectFromComponent( instance );
                if ( gameObj )
					scene = gameObj.scene;
			}

			cache.Add(instance, scene);
			return scene;
		}
Esempio n. 53
0
 public void OnSceneWasLoaded(Scene scene, LoadSceneMode m) { OnSceneLoaded(); }
 /// <summary>
 ///   <para>Close the scene. If removeScene flag is true, the closed scene will also be removed from EditorSceneManager.</para>
 /// </summary>
 /// <param name="scene">The scene to be closed/removed.</param>
 /// <param name="removeScene">Bool flag to indicate if the scene should be removed after closing.</param>
 /// <returns>
 ///   <para>Returns true if the scene is closed/removed.</para>
 /// </returns>
 public static bool CloseScene(Scene scene, bool removeScene)
 {
   return EditorSceneManager.INTERNAL_CALL_CloseScene(ref scene, removeScene);
 }
 private static extern bool INTERNAL_CALL_SaveScene(ref Scene scene, string dstScenePath, bool saveAsCopy);
 /// <summary>
 ///   <para>Mark the scene as modified.</para>
 /// </summary>
 /// <param name="scene">The scene to be marked as modified.</param>
 public static bool MarkSceneDirty(Scene scene)
 {
   return EditorSceneManager.INTERNAL_CALL_MarkSceneDirty(ref scene);
 }
Esempio n. 57
0
        protected virtual void OnSceneLoaded(Scene scene, LoadSceneMode mode)
        {
            // Ignore additive scene loads
            if (mode == LoadSceneMode.Additive)
            {
                return;
            }

            // We first assume that this is a 'normal' scene load rather than a saved game being loaded.
            // If we subsequently receive a notification that a saved game was loaded then the load action 
            // set here will be overridden by the OnSavePointLoaded callback above.

            if (loadAction == null)
            {
                loadAction = ExecuteStartBlock;
            }
        }
		static void MergeScenes()
		{
			Scene activeScene = new Scene();
			AmsMultiSceneSetup activeSetup = null;
			List<AmsMultiSceneSetup.SceneEntry> bakedScenes = new List<AmsMultiSceneSetup.SceneEntry>();

			GetCommonParameters( ref activeScene, ref activeSetup, bakedScenes );
			if ( bakedScenes.Count < 1 )
				return;

			AmsDebug.Log( null, "Running MergeScenes on Scene {0}", activeScene.name );

			foreach( var entry in bakedScenes )
			{
				if ( !entry.scene.isLoaded )
				{
					AmsDebug.LogError( activeSetup, "Could not merge non-loaded scene: {0}", entry.scene.name );
					continue;
				}

				var sourceCrossRefs = AmsCrossSceneReferences.GetSceneSingleton( entry.scene.scene, false );
				if ( sourceCrossRefs )
					GameObject.DestroyImmediate( sourceCrossRefs.gameObject, false );

				AmsDebug.Log( null, "Merging {0} into {1}", entry.scene.name, activeScene.name );
				EditorSceneManager.MergeScenes( entry.scene.scene, activeScene );
			}
		} // MergeScenes
 private static extern void INTERNAL_CALL_OpenScene(string scenePath, OpenSceneMode mode, out Scene value);
Esempio n. 60
0
        /// <summary>
        /// Method used to load the scene additively.
        /// 
        /// When loading a scene, it means that is the first time that it will be activated after it was previously destroyed.
        /// 
        /// This means that no subscene should be loaded
        /// </summary>
        public void LoadSceneAdditive()
        {
            //Application.LoadLevelAdditive(m_name);
            SceneManager.LoadScene(m_name, UnityEngine.SceneManagement.LoadSceneMode.Additive);
            m_scene = SceneManager.GetSceneByName(m_name);

            m_loaded = true;
            m_activated = true;
            m_subscenes.Clear();
        }