コード例 #1
0
 private void SceneUnloaded(Scene scene)
 {
     if (scene == missionScene)
     {
         missionScene = null;
     }
 }
コード例 #2
0
 private void PlaySceneOutAnim(Scene?currentScene)
 {
     if (currentScene == null)
     {
         return;
     }
     Debug.LogWarning("Implement Scene Out Anim here");
     //TODO
     //Move out current scene here
 }
コード例 #3
0
        public async Task Unload()
        {
            if (!currentScene.HasValue)
            {
                return;
            }

            await SceneManager.UnloadSceneAsync(currentScene.Value);

            currentScene = null;
        }
コード例 #4
0
        public static void OpenObjectInScene(PathInfo pathInfo)
        {
            // Debug.Log("[SceneUtil] Opening object:" + pathInfo.FullPath());
            Scene?scene = SceneUtil.LoadScene(pathInfo.assetPath, OpenSceneMode.Single);

            if (scene.HasValue)
            {
                UnityEngine.Object obj = pathInfo.objID.searchForObjectInScene(scene.Value);
                Selection.activeObject = obj;
            }
        }
コード例 #5
0
    public void AssignOpenScene(Scene sceneForChunk)
    {
        if (Loaded || _loading)
        {
            SceneManager.UnloadSceneAsync(sceneForChunk);
            return;
        }

        _scene = sceneForChunk;
        RelocateChunkObjectsToChunk(_scene.Value.GetRootGameObjects());
    }
コード例 #6
0
    /// <summary>
    /// Start a minigame that is in a separate scene which will be additively loaded on top of the current scene.
    /// The scene should have its own Camera since the main camera will be disabled.
    /// Remember to add the scene to BuildSettings
    /// Calling Exit will unload the additive scene.
    /// </summary>
    public void EnterScene(string additiveSceneName)
    {
        EnterInternal(disableCamera: true);

        IsMiniGameSceneActive = true;
        RenderSettings.fog    = false;
        SetMainSceneObjectsEnabled(false);

        SceneManager.LoadScene(additiveSceneName, LoadSceneMode.Additive);
        Scene = SceneManager.GetSceneByName(additiveSceneName);
    }
コード例 #7
0
		/*--------------------------------------------------------------------------------------------*/
		private void LoadSceneForNonplayingEditor() {
#if UNITY_EDITOR
			string fullPath = Application.dataPath+"/"+SceneFolderPath+SceneName+".unity";

			vLoadedScene = UnityEditor.SceneManagement.EditorSceneManager.OpenScene(
				fullPath, UnityEditor.SceneManagement.OpenSceneMode.Additive);

			Debug.Log("Loaded scene for editor: "+fullPath, this);
			OnSceneLoadedEvent.Invoke(this);
#endif
		}
コード例 #8
0
        public bool TranslateText(Scene?scene, object source, TextTranslationEventArgs e, out string translate)
        {
            if (TextTranslationPool.Translate(scene, source, e, out var temp))
            {
                translate = temp;
                return(true);
            }

            translate = temp;
            return(false);
        }
コード例 #9
0
ファイル: ScenarioMapManager.cs プロジェクト: lgsvl/simulator
 /// <summary>
 /// Unloads current map asynchronously
 /// </summary>
 public void UnloadMapAsync()
 {
     if (string.IsNullOrEmpty(loadedSceneName))
     {
         return;
     }
     LaneSnapping.Deinitialize();
     SceneManager.UnloadSceneAsync(loadedSceneName);
     loadedSceneName = null;
     loadedScene     = null;
 }
コード例 #10
0
        /// Dictate the type of UI to look for when scene is loaded.
        /// Pass in the UIDataEvent, you create and manage your own UIDataEvent.
        /// All UIs only add to the scene.
        public SceneControllerToken <TModel> LoadSceneControllerAsync <TModel>(TModel model, Transform parent = null, LoadSceneMode loadSceneMode = LoadSceneMode.Additive)
            where TModel : SceneControllerModel
        {
            var controllerName = DeriveControllerName <TModel>();
            var token          = new SceneControllerToken <TModel>(Guid.NewGuid(), model);

            scene = null;
            AsyncOperation asyncOperation = SceneManager.LoadSceneAsync(controllerName, loadSceneMode);

            RunCoroutine.Instance.StartCoroutine(LoadController <TModel>(asyncOperation, token, controllerName, parent));
            return(token);
        }
コード例 #11
0
    private void ClientSceneReady(NetworkConnection connection, SceneReadyMessage message)
    {
        Scene?scene = SceneManagerExtensions.GetSceneByPathOrName(message.sceneNameOrPath);

        if (scene == null)
        {
            Debug.LogWarning($"Scene {message.sceneNameOrPath} not loaded on server despite client readying it");
            return;
        }

        PlayerForConnection(connection).MoveToScene(scene.Value);
    }
コード例 #12
0
 /// <summary>
 /// End the scene
 /// </summary>
 /// <exception cref="InvalidOperationException"></exception>
 public void EndScene()
 {
     // Throw an exception if there is no current scene
     if (CurrentScene == null)
     {
         throw new InvalidOperationException("There is no currently active scene");
     }
     // End the current scene, if any
     Log.Info($"Ending scene \"{CurrentScene.Name}\"", nameof(SceneManager));
     CurrentScene.End();
     CurrentScene = null;
 }
コード例 #13
0
 /// <summary>
 /// End the current scene, if any, and start a scene
 /// </summary>
 /// <param name="scene"></param>
 public void StartScene(Scene scene, double time)
 {
     // End the current scene, if any
     if (CurrentScene != null)
     {
         EndScene();
     }
     // Start new scene
     Log.Info($"Starting scene \"{scene.Name}\"", nameof(SceneManager));
     CurrentScene = scene;
     CurrentScene.Start();
 }
 public UnityObjectOptionTree(Type type, Scene?scene, string title = null) : this
     (
         type,
         type.DisplayName(),
         type.Icon(),
         scene,
         true,
         uo => true,
         title ?? type.DisplayName()
     )
 {
 }
コード例 #15
0
    public static T FindFirstObject <T>(Scene?scene = null, bool includeInactive = true) where T : Component
    {
        foreach (var rootObject in GetRootGameObjects(scene))
        {
            if (rootObject.GetComponentsInChildren <T>(includeInactive).FirstOrDefault() is T t)
            {
                return(t);
            }
        }

        return(null);
    }
コード例 #16
0
        private static void CollectHierarchyObjects()
        {
            // 実行中は負荷が高いので実行しない.
            if (Application.isPlaying)
            {
                return;
            }

            currentScene = SceneManager.GetSceneAt(0);

            hierarchyObjects = UnityEditorUtility.FindAllObjectsInHierarchy();
        }
コード例 #17
0
        private static void HierarchyChanged()
        {
            // 実行中は負荷が高いので実行しない.
            if (Application.isPlaying)
            {
                return;
            }

            if (onHierarchyChangedAsObservable != null)
            {
                onHierarchyChangedAsObservable.OnNext(Unit.Default);
            }

            var createObserver = onCreateAsObservable != null && onCreateAsObservable.HasObservers;
            var deleteObserver = onDeleteAsObservable != null && onDeleteAsObservable.HasObservers;

            if (createObserver || deleteObserver)
            {
                var nowScene = SceneManager.GetActiveScene();

                // Hierarchy上のGameObjectを検索して取得.
                hierarchyObjects = UnityEditorUtility.FindAllObjectsInHierarchy();

                // シーンが変わっていた場合Hierarchy上のGameObjectをキャッシュ.
                if (currentScene != nowScene)
                {
                    markedObjects = hierarchyObjects.Select(x => x.GetInstanceID()).ToArray();
                    currentScene  = nowScene;
                }

                // キャッシュ済みGameObjectとの差分で新規作成されたGameObjectを発見.
                var newObjects = hierarchyObjects.Where(x => !markedObjects.Any(y => y == x.GetInstanceID())).ToArray();

                // 新規作成通知.
                if (0 < newObjects.Length)
                {
                    if (onCreateAsObservable != null)
                    {
                        onCreateAsObservable.OnNext(newObjects.ToArray());
                    }
                }

                if (hierarchyObjects.Length < markedObjects.Length)
                {
                    if (onDeleteAsObservable != null)
                    {
                        onDeleteAsObservable.OnNext(Unit.Default);
                    }
                }

                markedObjects = hierarchyObjects.Select(x => x.GetInstanceID()).ToArray();
            }
        }
コード例 #18
0
        /// <summary>
        /// Helper method to get the DontDestroyOnLoad Scene.  It's inaccessible by standard Unity methods.
        /// </summary>
        /// <returns>The DontDestroyOnLoad Scene.</returns>
        private static Scene GetDontDestroyOnLoadScene()
        {
            if (!_dontDestroyOnLoadScene.HasValue)
            {
                GameObject temp = new GameObject("AMS-DontDestroyOnLoad-Finder");
                Object.DontDestroyOnLoad(temp);

                _dontDestroyOnLoadScene = temp.scene;
                Object.DestroyImmediate(temp);
            }

            return(_dontDestroyOnLoadScene.Value);
        }
コード例 #19
0
        public static void Prompt(Scene?defaultParentScene, Action <Scene?, Transform> onConfirm)
        {
            if (instance == null)
            {
                var instance = CreateInstance <ReparentingPrompt>();
                instance.minSize = instance.maxSize = new Vector2(300, 88);
            }

            instance.parentScene = defaultParentScene;
            instance.onConfirm   = onConfirm;
            instance.ShowUtility();
            instance.Center();
        }
コード例 #20
0
ファイル: PodLoadingScript.cs プロジェクト: toth3max/PodVR
	// Use this for initialization
	void Start ()
	{

        SceneStartingScene = SceneManager.GetActiveScene();
        if (LevelCache.IsLoaded(SceneStartingScene.name)){
            return;
        } else {
            LevelCache.CurrentRootObject = SceneStartingScene.name;
        }

        DontDestroyOnLoad(gameObject);
        currentScene = SceneStartingScene;
		IsLoading = true;
	}
コード例 #21
0
        private static void CollectHierarchyObjects()
        {
            // 実行中は負荷が高いので実行しない.
            if (Application.isPlaying)
            {
                return;
            }

            var nowScene = SceneManager.GetSceneAt(0);

            hierarchyObjects = UnityEditorUtility.FindAllObjectsInHierarchy();
            markedObjects    = hierarchyObjects.Select(x => x.GetInstanceID()).ToArray();
            currentScene     = nowScene;
        }
コード例 #22
0
    public static void LaunchEvolutionScene()
    {
        //Evolution scene controller entrance arguments should have already been set before launching scene
        //Previous scene should have paused itself before launching the evolution scene

        if (evolutionScene != null)
        {
            Debug.LogError("Evolution scene trying to be launched while one already active");
            return;
        }

        EvolutionSceneClosed = null;

        Scene oldScene = CurrentScene;

        EvolutionSceneClosed += () =>
        {
            SceneManager.SetActiveScene(oldScene);
        };

        StartFadeOut();

        FadeOutComplete += () =>
        {
            int newSceneIndex = SceneManager.sceneCount;

            AsyncOperation loadSceneOperation = SceneManager.LoadSceneAsync(evolutionSceneIdentifier, LoadSceneMode.Additive);

            loadSceneOperation.completed += (ao) =>
            {
                evolutionScene = SceneManager.GetSceneAt(newSceneIndex);

                EvolutionScene.EvolutionSceneController evolutionSceneController = EvolutionScene.EvolutionSceneController.GetEvolutionSceneController((Scene)evolutionScene);

                SceneManager.SetActiveScene((Scene)evolutionScene);

                StartFadeIn();

                FadeInComplete += () =>
                {
                    evolutionSceneController.StartAnimation();

                    evolutionSceneController.EvolutionAnimationComplete += () =>
                    {
                        CloseEvolutionScene();
                    };
                };
            };
        };
    }
コード例 #23
0
        public void Load(string fileName)
        {
            _context = new AssimpContext();

            _context.SetConfig(new BooleanPropertyConfig(AiConfigs.AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS, false));

            _fileName = fileName;
            _scene    = _context.ImportFile(fileName,
                                            PostProcessSteps.GenerateBoundingBoxes |
                                            PostProcessSteps.CalculateTangentSpace |
                                            PostProcessSteps.EmbedTextures);
            _sceneContext.CurrentScene = _scene;
            _materialProvider.Load(_scene);
        }
コード例 #24
0
        private void SetSceneActive(Scene?scene)
        {
            if (!scene.HasValue)
            {
                return;
            }

            if (!scene.Value.IsValid())
            {
                return;
            }

            SceneManager.SetActiveScene(scene.Value);
        }
コード例 #25
0
        //----- method -----

        public SceneInstance(Scenes?identifier, ISceneBase instance, Scene?scene)
        {
            this.scene = scene;

            Identifier = identifier;
            Instance   = instance;

            var rootObjects = scene.Value.GetRootGameObjects();

            activeRoots = rootObjects
                          .Where(x => !UnityUtility.IsNull(x))
                          .Where(x => UnityUtility.IsActive(x))
                          .ToArray();
        }
コード例 #26
0
ファイル: ExamplesHubSystem.cs プロジェクト: XRTK/Examples
        private void SceneManager_SceneLoaded(Scene scene, LoadSceneMode mode)
        {
            if (scene.buildIndex == 0)
            {
                // We don't care for the base scene loading. The base scene will always load
                // first when the application launches.
                return;
            }

            Assert.IsTrue(mode == LoadSceneMode.Additive, $"Only {nameof(LoadSceneMode.Additive)} scene loading is allowed!");
            currentExampleScene = scene;

            // While we have an exmaple scene loaded we want the examples selection to disappear.
            ExamplesUI.SetActive(false);
        }
コード例 #27
0
    void OnCollisionExit(Collision col)
    {
        if (col.transform.tag != "Player")
        {
            return;
        }
        if (_scene == null)
        {
            throw new NullReferenceException();
        }

        col.transform.parent = null;
        SceneManager.MoveGameObjectToScene(col.gameObject, (Scene)_scene);
        _scene = null;
    }
コード例 #28
0
    IEnumerator ToLevel(int levelIndex, bool useFade = true)
    {
        if (levelIndex < 0 || levelIndex >= this.TotalLevels)
        {
            yield break;
        }
        else if (this.loading)
        {
            yield break;
        }

        this.loading = true;

        // Fade..
        if (this.fadeEffect != null && useFade)
        {
            yield return(this.fadeEffect.FadeOut());
        }

        if (this.LastScene != null)
        {
            var u = this.LastScene.Value;
            if (u.isLoaded && u.IsValid())
            {
                yield return(SceneManager.UnloadSceneAsync(u));
            }
        }

        this.CurrentLevel = levelIndex;

        var count = SceneManager.sceneCount;

        yield return(SceneManager.LoadSceneAsync(levelIndex + 1, LoadSceneMode.Additive));

        var s = SceneManager.GetSceneAt(count);

        if (this.fadeEffect != null && useFade)
        {
            yield return(this.fadeEffect.FadeIn());
        }

#if UNITY_EDITOR
        Debug.Log("Level: " + this.CurrentLevel.ToString() + "/ " + this.TotalLevels.ToString());
#endif

        this.LastScene = s;
        this.loading   = false;
    }
コード例 #29
0
    public static void LaunchTradeScene()
    {
        if (tradeScene != null)
        {
            Debug.LogError("Trade trying to be launched while battle already active");
            return;
        }

        if (pausedFreeRoamScene != null)
        {
            Debug.LogError("Trying to launch trade scene while there is already a paused scene");
            return;
        }

        pausedFreeRoamScene = CurrentScene;
        FreeRoamSceneController pausedSceneController = GetFreeRoamSceneController((Scene)pausedFreeRoamScene);

        pausedSceneController.SetDoorsEnabledState(false);
        pausedSceneController.SetSceneRunningState(false);

        StartFadeOut();

        FadeOutComplete += () =>
        {
            pausedSceneController.SetSceneRunningState(true);
            pausedSceneController.SetEnabledState(false);

            int newSceneIndex = SceneManager.sceneCount;

            AsyncOperation loadSceneOperation = SceneManager.LoadSceneAsync(tradeSceneIdentifier, LoadSceneMode.Additive);

            loadSceneOperation.completed += (ao) =>
            {
                tradeScene = SceneManager.GetSceneAt(newSceneIndex);

                Trade.TradeManager tradeManager = Trade.TradeManager.GetTradeSceneTradeManager((Scene)tradeScene);

                SceneManager.SetActiveScene((Scene)tradeScene);

                StartFadeIn();

                FadeInComplete += () =>
                {
                    tradeManager.StartTradeScene();
                };
            };
        };
    }
コード例 #30
0
ファイル: Textures.cs プロジェクト: Dersei/Aethra
        public void CreateScene(int width, int height, FloatColor color, bool useAntialiasing)
        {
            var renderTarget = new Framebuffer(width, height);

            renderTarget.Clear(color);
            var camera           = new PerspectiveCamera(renderTarget, new Vector3(0f, 0, -10), Vector3.Forward, Vector3.Up);
            var objects          = new List <IHittable>();
            var circuitryTexture = Texture.LoadFrom(@"_Resources/Textures/circuitry-albedo.png").ToInfo(3);
            var sunTexture       = Texture.LoadFrom(@"_Resources/Textures/sun.png").ToInfo();
            var modelTexture     = Texture.LoadFrom(@"_Resources/Textures/texel_density.png").ToInfo();
            var crystalTexture   = Texture.LoadFrom(@"_Resources/Textures/crystal.png").ToInfo();

            var circuitryMaterial = new PhongMaterial(FloatColor.White, 1f, 8, 50, 0.5f,
                                                      circuitryTexture);
            var sunMaterial = new PhongMaterial(FloatColor.White, 1f, 8, 50, 1f,
                                                sunTexture);
            var modelMaterial = new PhongMaterial(FloatColor.White, 1f, 8, 50, 1f,
                                                  modelTexture);
            var crystalMaterial = new PhongMaterial(FloatColor.White, 1f, 8, 50, 1f,
                                                    crystalTexture);

            var circuitry = new Sphere(new Vector3(2.5f, -1, 0), 0.5f, circuitryMaterial);
            var sun       = new Sphere(new Vector3(2.5f, -2.5f, 0), 0.75f, sunMaterial);
            var model     = Model.LoadFromFile("_Resources/Models/lowpolytree_unwrap.obj", modelMaterial, 1, Vector3.Down);
            var crystal   = Model.LoadFromFile("_Resources/Models/crystal.obj", crystalMaterial, 3, Vector3.Left * 2);

            objects.Add(circuitry);
            objects.Add(sun);
            objects.Add(model);
            objects.Add(crystal);

            Scene = new Scene(objects, camera,
                              new List <Light>
            {
                new PointLight {
                    Position = new Vector3(1, 2f, 0), Color = FloatColor.White
                },
                new PointLight {
                    Position = new Vector3(-2, 2f, 0), Color = FloatColor.Red
                },
                new PointLight {
                    Position = new Vector3(-4, 2f, -3), Color = FloatColor.White
                },
                new PointLight {
                    Position = new Vector3(-2, -1f, 0), Color = FloatColor.Green
                },
            }, FloatColor.Black);
        }
コード例 #31
0
    IEnumerator ExitInternal()
    {
        // unload all additive minigame scenes. don't leave cutscene mode until its done to avoid weirdness
        if (Scene.HasValue)
        {
            yield return(SceneManager.UnloadSceneAsync(Scene.Value));

            Scene = null;
        }

        CutsceneMode.Exit();
        IsMiniGameActive = false;

        Globals.GameVars.camera_Mapview.SetActive(true);
        Globals.GameVars.FPVCamera.SetActive(true);
    }
コード例 #32
0
        void UpdateSceneUI()
        {
            if (_loadedScene.HasValue)
            {
                SceneManager.UnloadSceneAsync(_loadedScene.Value);
                _loadedScene = null;
            }

            DemoDescription desc      = demoScenes[_currentSceneIndex];
            string          scenename = desc.sceneName + scenePostfix;

            SceneManager.LoadSceneAsync(scenename, LoadSceneMode.Additive);
            demoNameText.text = desc.name;
            demoInfoText.text = desc.info;
            _loadedScene      = SceneManager.GetSceneByName(scenename);
        }
コード例 #33
0
ファイル: PodLoadingScript.cs プロジェクト: toth3max/PodVR
	public void Loading()
	{
        try {
            if (currentScene.Value.isLoaded) {
                var rootObject = CreateRoomObject(currentScene.Value.name);
                AddLevelToCache(currentScene.Value, rootObject);
                CurrenSceneIndex++;
                SceneManager.LoadScene(CurrenSceneIndex, LoadSceneMode.Additive);
                currentScene = SceneManager.GetSceneAt(CurrenSceneIndex);
            }
        } catch (IndexOutOfRangeException) {
            Debug.Log("Out of range exit");
            LevelCache.LevelMap[SceneStartingScene.name].gameObject.SetActive(true);
            IsLoading = false;
        }
	}
コード例 #34
0
    private void SceneChanged(Scene oldScene, Scene newScene)
    {
        if (SpaceTraderConfig.LocalPlayer)
        {
            return;
        }

        /* if loading into a new scene with no player, and it's a mission scene,
         start that mission */
        var missionForScene = SpaceTraderConfig.MissionsConfiguration.MissionForScene(newScene);
        if (missionForScene)
        {
            Debug.Assert(!missionScene.HasValue, "can't load two missions scenes at once");

            missionScene = newScene;
            Mission = ActiveMission.Create(missionForScene);
        }
        else if (mission)
        {
            CancelMission();
        }
    }