GetActiveScene() public static method

Gets the currently active scene.

public static GetActiveScene ( ) : Scene
return Scene
示例#1
0
    void Update()
    {
        if (SceneManager.GetActiveScene().name == "Level Select")
        {
            Time.timeScale = 1;
        }
        if (SceneManager.GetActiveScene().name != PrevScene)
        {
            IEnumerator Fade = FadeOutMusic();
            // GetComponent<AudioSource>().volume = 0;
            if (SceneManager.GetActiveScene().name == "Level Select" ||
                SceneManager.GetActiveScene().name == "End Game")
            {
                Time.timeScale = 1f;
                if (!CurrentlyFading)
                {
                    StartCoroutine(Fade);
                }
            }
            else
            {
                StopCoroutine(Fade);
            }
        }

//        if (SceneManager.GetActiveScene().name != "Level Select" && GetComponent<AudioSource>().isPlaying)
//            GetComponent<AudioSource>().volume = 1f;

        PrevScene = SceneManager.GetActiveScene().name;
    }
示例#2
0
        protected override void OnInstanceInit()
        {
            mCurScene         = UnitySceneManager.GetActiveScene();
            mFirstSceneLoaded = new SceneAssetPath(mCurScene);

            if (!_rootScene.isValid)
            {
                _rootScene = mFirstSceneLoaded;
            }

            //mIsFullscreen = Screen.fullScreen;

            mPauseCounter = 0;

            mTransitions = new List <ITransition>();

            if (stackEnable)
            {
                mSceneStack = new Stack <string>(stackCapacity);
            }

            mScenesAdded = new List <Scene>();
            mScenesToAdd = new Queue <string>();

            mScenesToRemove = new Queue <Scene>();
        }
示例#3
0
            private IEnumerator Start()
            {
                yield return(new WaitForSceneLoadFinish());

                Scene s = USceneManager.GetActiveScene();

                foreach (var g in s.GetRootGameObjects())
                {
                    if (g.name.Contains("_Transition") || g.layer == (int)GlobalEnums.PhysLayers.TRANSITION_GATES || g.GetComponent <TransitionPoint>() != null)
                    {
                        if (SetupMode)
                        {
                            g.gameObject.AddComponent <ShowColliders>();
                        }
                        Logger.LogDebug($"Skip gate object:{g.name}");
                        continue;
                    }
                    if (g.GetComponent <CustomDecoration>() != null)
                    {
                        continue;
                    }
                    Destroy(g.gameObject);
                }
                UnVisableBehaviour.AttackReact.Create(gameObject);
            }
示例#4
0
    // Start is called before the first frame update
    public virtual void Start()
    {
        currentScene = UnitySceneManager.GetActiveScene().name;
        if (UnitySceneManager.GetActiveScene().name == "Scene2" && GameObject.Find("GlobalObject").GetComponent <GlobalControl>().killedSchnap)
        {
            GameObject.Find("Schnap").SetActive(false);
        }

        else
        {
            return;
        }

        if (UnitySceneManager.GetActiveScene().name == "SchnapHouse" && GameObject.Find("GlobalObject").GetComponent <GlobalControl>().killedSchnap)
        {
            houseDeathScene    = GameObject.Find("Switch").GetComponent <KillTrigger>().houseDeath;
            houseObject        = GameObject.Find("Switch").GetComponent <KillTrigger>().house;
            houseObject.sprite = houseDeathScene;
            GameObject.Find("Schnap").SetActive(false);
        }
        else
        {
            return;
        }
    }
示例#5
0
    private void Start()
    {
        if (!dopeInteracted && GameObject.Find("Dopermine") && UnitySceneManager.GetActiveScene().name == "Scene1")
        {
            GameObject.Find("SpearKillTrigger").GetComponent <SpearKill>().enabled = true;
        }
        else if (dopeInteracted && GameObject.Find("Dopermine") && UnitySceneManager.GetActiveScene().name == "Scene1")
        {
            GameObject.Find("SpearKillTrigger").GetComponent <SpearKill>().enabled = false;
        }

        /*if (schnapInteracted && UnitySceneManager.GetActiveScene().name == "Scene2")
         * {
         *  GameObject.Find("Schnap").SetActive(false);
         * }
         * else if (killedSchnap && GameObject.Find("Schnap") && UnitySceneManager.GetActiveScene().name == "Scene2")
         * {
         *  GameObject.Find("Schnap").SetActive(false);
         * }
         * else if (killedSchnap && GameObject.Find("Schnap") && UnitySceneManager.GetActiveScene().name == "SchnapHouse")
         * {
         *  GameObject.Find("Schnap").SetActive(false);
         *
         *  house.sprite = houseDeathScene;
         *
         * }*/
    }
示例#6
0
    // Update is called once per frame
    void Update()
    {
        if (UnitySceneManager.GetActiveScene().name == "End")
        {
            if (dopermineHealth.GetComponent <Damage>().health <= 0)
            {
                Destroy(GameObject.Find("Spear")); Destroy(GameObject.Find("MagicBall"));

                gameObject.GetComponent <PauseButton>().enabled = false;

                GameObject.Find("Dopermine").GetComponent <Attack>().CancelInvoke("AfterEverySecond");
                GameObject.Find("Genrad").GetComponent <PlayerStats>().HP      = 100;
                GameObject.Find("Genrad").GetComponent <PlayerStats>().stamina = 100;
                GameObject.Find("Genrad").GetComponent <PlayerStats>().items   = new string[0];

                globalObject.GetComponent <GlobalControl>().schnapInteracted       = false;
                globalObject.GetComponent <GlobalControl>().dopeInteracted         = false;
                globalObject.GetComponent <GlobalControl>().killedSchnap           = false;
                GameObject.Find("Genrad").GetComponent <PlayerStats>().openedChest = false;

                GameObject.Find("DisplayInformation").GetComponent <Canvas>().enabled = false;

                dopermineDying.Play();
            }

            if (globalObject.GetComponent <GlobalControl>().HP <= 0)
            {
                Destroy(GameObject.Find("Spear")); Destroy(GameObject.Find("MagicBall"));

                gameObject.GetComponent <PauseButton>().enabled = false;
                GameObject.Find("Dopermine").GetComponent <Attack>().CancelInvoke("AfterEverySecond");
                GameObject.Find("Genrad").GetComponent <PlayerStats>().HP      = 100;
                GameObject.Find("Genrad").GetComponent <PlayerStats>().stamina = 100;
                GameObject.Find("Genrad").GetComponent <PlayerStats>().items   = new string[0];

                globalObject.GetComponent <GlobalControl>().schnapInteracted       = false;
                globalObject.GetComponent <GlobalControl>().dopeInteracted         = false;
                globalObject.GetComponent <GlobalControl>().killedSchnap           = false;
                GameObject.Find("Genrad").GetComponent <PlayerStats>().openedChest = false;

                GameObject.Find("DisplayInformation").GetComponent <Canvas>().enabled = false;

                genradDeath.Play();
            }
        }
        if (UnitySceneManager.GetActiveScene().name == "End")
        {
            if (dopermineDying.state.ToString() == "Playing" ^
                genradDeath.state.ToString() == "Playing" ^
                happyEnding.state.ToString() == "Playing")
            {
                if (Input.GetKeyDown(KeyCode.Escape))
                {
                    GameObject.Find("GameController").GetComponent <SceneController>().LoadScene("Menu");
                }
            }
        }
    }
        private IEnumerator Start()
        {
            var scene   = UnitySceneManager.GetActiveScene();
            var context = FindSceneContext(scene.name);

            yield return(new WaitUntil(() => context.Initialized));

            Next(scene.name, null, TransMode.None);
        }
示例#8
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown("escape"))
     {//When a key is pressed down it see if it was the escape key if it was it will execute the code
         if (UnitySceneManager.GetActiveScene().buildIndex == 0)
         {
             popUpExit.SetActive(true);
             yes.onClick.AddListener(exit);
             no.onClick.AddListener(scene0);
         }
         else if (UnitySceneManager.GetActiveScene().buildIndex == 1)
         {
             UnitySceneManager.LoadScene(0);
         }
         else if (UnitySceneManager.GetActiveScene().buildIndex == 2)
         {
             popUpExit.SetActive(true);
             yes.onClick.AddListener(scene0);
             no.onClick.AddListener(scene2);
         }
         else if (UnitySceneManager.GetActiveScene().buildIndex == 3)
         {
             popUpExit.SetActive(true);
             yes.onClick.AddListener(scene0);
             no.onClick.AddListener(scene3);
         }
         else if (UnitySceneManager.GetActiveScene().buildIndex == 4)
         {
             UnitySceneManager.LoadScene(2);
         }
         else if (UnitySceneManager.GetActiveScene().buildIndex == 5)
         {
             UnitySceneManager.LoadScene(4);
         }
         else if (UnitySceneManager.GetActiveScene().buildIndex == 6)
         {
             UnitySceneManager.LoadScene(5);
         }
         else if (UnitySceneManager.GetActiveScene().buildIndex == 7)
         {
             UnitySceneManager.LoadScene(6);
         }
         else if (UnitySceneManager.GetActiveScene().buildIndex == 8)
         {
             UnitySceneManager.LoadScene(7);
         }
         else if (UnitySceneManager.GetActiveScene().buildIndex == 9)
         {
             UnitySceneManager.LoadScene(8);
         }
         else if (UnitySceneManager.GetActiveScene().buildIndex == 14)
         {
             UnitySceneManager.LoadScene(2);
         }
     }
 }
 public void BackToMenu()
 {
     Time.timeScale = 1;
     if (Manager.GetActiveScene().name == "Menu")
     {
         return;
     }
     NetworkHandler.Instance.Disconnect();
     LoadScene("Menu");
 }
示例#10
0
    IEnumerator RestartScene()
    {
        AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().name);

        //Wait until the last operation fully loads to return anything
        while (!asyncLoad.isDone)
        {
            yield return(null);
        }
    }
示例#11
0
    /// <summary>
    /// Same as GameObject.FindObjectsOfType<T>, but also get inactive objects
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <returns></returns>
    public static T[] FindAllOfType <T>() where T : UnityEngine.Object
    {
        if (typeof(T) == typeof(GameObject))
        {
            throw new Exception("Use Transform instead of GameObject when calling GameObjectEx.FindAllOfType<>");
        }

        return(Resources.FindObjectsOfTypeAll <T>()
               .Where(obj => obj.GameObject().scene == SceneManager.GetActiveScene())
               .ToArray());
    }
示例#12
0
        private async UniTask Load(string sceneName, Action <DiContainer> extraBindings)
        {
            var currentScene = UnitySceneManager.GetActiveScene();

            await LoadAdditive(sceneName, extraBindings);

            var nextScene = UnitySceneManager.GetSceneByName(sceneName);

            UnitySceneManager.SetActiveScene(nextScene);

            await UnitySceneManager.UnloadSceneAsync(currentScene);
        }
示例#13
0
    private void Start()
    {
        // 最初に再生したシーンを設定する。
        UnityScene unityScene     = UnitySceneManager.GetActiveScene();
        string     unitySceneName = unityScene.name;
        SceneBase  scene          = GameObject.Find(unitySceneName).GetComponent <SceneBase>();

        scene.Setup(GetSceneID(ref unitySceneName), unityScene);
        sceneList.Add(scene);

        UnitySceneManager.SetActiveScene(unityScene);
    }
示例#14
0
 void Start()
 {
     if (Manager.GetActiveScene().name == "Main Menu")
     {
         GetComponent <AudioSource>().loop = true;
         GetComponent <AudioSource>().clip = audioManager.GetClip("MenuMusic");
         GetComponent <AudioSource>().Play();
         inGame = false;
     }
     else
     {
         inGame = true;
     }
 }
示例#15
0
    private IEnumerator WaitUntilSceneLoaded(string sceneName, System.Action onSceneLoaded)
    {
        Debug.LogFormat("[SceneManager] WaitUntilSceneLoaded(sceneName = {0}, onSceneLoaded = {1})", sceneName, onSceneLoaded);
        while (SManager.GetActiveScene().name.Equals(sceneName) == false)
        {
            yield return(null);
        }

        Debug.LogFormat("[SceneManager] Scene loaded done");

        if (onSceneLoaded != null)
        {
            onSceneLoaded();
        }
    }
示例#16
0
        public IEnumerator Dump(string sceneName = null)
        {
            List <string> scenes = new List <string>();

            for (int j = 0; j < USceneManager.sceneCountInBuildSettings; j++)
            {
                string scenePath = SceneUtility.GetScenePathByBuildIndex(j);
                string name      = Path.GetFileNameWithoutExtension(scenePath);
                scenes.Add(name);
                var load = USceneManager.LoadSceneAsync(j, LoadSceneMode.Single);
                while (!load.isDone)
                {
                    yield return(new WaitForEndOfFrame());
                }
                yield return(new WaitForSeconds(0.2f));

                Scene         s  = USceneManager.GetActiveScene();
                StringBuilder sb = new StringBuilder();
                foreach (var g in s.GetRootGameObjects())
                {
                    Visit(g.transform, 0, null, sb);
                }
                try
                {
                    var          fs = File.Create($"Z:\\1\\{s.name}.txt");
                    StreamWriter sw = new StreamWriter(fs);
                    sw.Write(sb.ToString());
                    sw.Close();
                    fs.Close();
                }
                catch { }

                //
            }
            var load_ = USceneManager.LoadSceneAsync(2, LoadSceneMode.Single);

            while (!load_.isDone)
            {
                yield return(new WaitForEndOfFrame());
            }
            yield return(USceneManager.LoadSceneAsync("Quit_To_Menu"));

            while (USceneManager.GetActiveScene().name != Constants.MENU_SCENE)
            {
                yield return(new WaitForEndOfFrame());
            }
        }
示例#17
0
    override protected void start()
    {
        this.curIdx       = 1;
        this.selectedItem = 0;

        this.listLevels();
        this.setupUi();
        this.setSelectorPosition();

        /* Avoid triggering the death scene while rendering the
         * level thumbnails */
        InputControlled.LevelSelectScene = SceneMng.GetActiveScene().name;

        base.start();

        this.StartCoroutine(this.startTakeSS());
    }
示例#18
0
        private void OnLoadSceneSuccess(object sender, GameFramework.Scene.LoadSceneSuccessEventArgs e)
        {
            m_MainCamera = Camera.main;
            if (SceneManager.GetActiveScene() == m_GameFrameworkScene)
            {
                Scene scene = SceneManager.GetSceneByName(GetSceneName(e.SceneAssetName));
                if (!scene.IsValid())
                {
                    Log.Error("Loaded scene '{0}' is invalid.", e.SceneAssetName);
                    return;
                }

                SceneManager.SetActiveScene(scene);
            }

            m_EventComponent.Fire(this, LoadSceneSuccessEventArgs.Create(e));
        }
示例#19
0
    private void onCenter(bool enter, RelPos p, GO other)
    {
        Type otherType = Type.Error;

        this.issueEvent <RemoteGetType>(
            (x, y) => x.Get(out otherType), other);
        if (otherType != Type.Player && otherType != Type.Minion)
        {
            /* Avoid triggering the death scene while rendering the
             * level thumbnails */
            if (SceneMng.GetActiveScene().name != LevelSelectScene)
            {
                Global.Sfx.playPlayerCrushed(this.fastGetTr());
                SceneMng.LoadSceneAsync("YouLose", SceneMode.Additive);
            }
            this.gameObject.SetActive(false);
        }
    }
示例#20
0
    void Start()
    {
        this.resetting      = false;
        this.doReset        = false;
        this.done           = false;
        this.loadingPause   = false;
        this.didSpawnPlayer = false;
        this.loaderScene    = SceneMng.GetActiveScene().buildIndex;
        /* Starts at 1 since there's always the player position */
        this.checkpointCount = 1;
        this.minionCount     = 0;
        this.minionSaved     = 0;
        this.minionCountTxt  = null;

        BaseRemoteAction.root = this.gameObject;

        this.StartCoroutine(this.load());
    }
示例#21
0
        void Update()
        {
            if (PreviousWeapon.Value.IsDown())
            {
                if (!inGame)
                {
                    Logger.LogWarning("You need to load a game first!");
                    return;
                }
                if (CustomWeapons.Count < 2)
                {
                    Logger.LogWarning("You don't have any custom weapons!");
                    return;
                }
                Logger.LogDebug($"Index: {CurrentWeaponIndex} => {Modulo(CurrentWeaponIndex - 1, CustomWeapons.Count)}");
                SwitchWeapon(Modulo(CurrentWeaponIndex - 1, CustomWeapons.Count));
            }
            if (NextWeapon.Value.IsDown())
            {
                if (!inGame)
                {
                    Logger.LogWarning("You need to load a game first!");
                    return;
                }
                if (CustomWeapons.Count < 2)
                {
                    Logger.LogWarning("You don't have any custom weapons!");
                    return;
                }
                Logger.LogDebug($"Index: {CurrentWeaponIndex} => {Modulo(CurrentWeaponIndex + 1, CustomWeapons.Count)}");
                SwitchWeapon(Modulo(CurrentWeaponIndex + 1, CustomWeapons.Count));
            }
#if DEBUG
            if (Input.GetKeyDown(KeyCode.F10))
            {
                MeshRenderer mesh = Weapon.GetComponent <MeshRenderer>();
                mesh.enabled = !mesh.enabled;
            }
            if (Input.GetKeyDown(KeyCode.F9))
            {
                Logger.LogInfo($"Scene: {UnitySceneManager.GetActiveScene().name}");
            }
#endif
        }
示例#22
0
        private IEnumerator Start()
        {
            var scene   = UnitySceneManager.GetActiveScene();
            var context = FindSceneContext(scene.name);

            yield return(new WaitUntil(() => context.Initialized));

            /*
             * _loadContext = new LoadContext() {
             *  NextScene = new SceneData() {
             *      Name = scene.name,
             *      Lifecycles = context.Container.ResolveAll<ISceneLifecycle>(),
             *  },
             *  AdditiveScenes = new List<SceneData>(),
             * };
             * _loadContext.NextScene.Lifecycles.ForEach(x => x.OnTransComplete());
             */
            Next(scene.name, null, TransMode.None);
        }
示例#23
0
        protected override void OnInstanceInit()
        {
            mRootScene = mCurScene = UnitySceneManager.GetActiveScene();
            //mIsFullscreen = Screen.fullScreen;

            mPrevTimeScale = Time.timeScale;

            isPaused = false;

            mTransitions = new List <ITransition>();

            if (stackEnable)
            {
                mSceneStack = new Stack <string>(stackCapacity);
            }

            mScenesAdded = new List <Scene>();
            mScenesToAdd = new Queue <string>();
        }
    void Awake()
    {
        if (Instanse == null)
        {
            RandomBarkChance = 0.2f;

            Instanse = this;
            DontDestroyOnLoad(gameObject);

            RaidingManager      = GetComponent <RaidManager>();
            ToolTipManager      = GetComponent <ToolTipManager>();
            DragManager         = GetComponent <DragManager>();
            LocalizationManager = GetComponent <LocalizationManager>();

            MainMenuUI   = GetComponentInChildren <Canvas>();
            MainUICamera = GameObject.FindGameObjectWithTag("Main UI Camera").GetComponent <Camera>();
            UpdateSceneOverlay(MainUICamera);

            database = GetComponent <DarkestDatabase>();
            database.Load();
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        if (SceneManager.GetActiveScene().name == "Dungeon")
        {
            LoadSave();
            if (SaveData.InRaid == false)
            {
                var raidPanel = FindObjectOfType <RaidPanel>();
                raidPanel.inventoryPanel.partyInventory.Initialize();
                Instanse.RaidingManager.QuickStart(raidPanel.inventoryPanel.partyInventory);
            }
        }
        else if (SceneManager.GetActiveScene().name == "EstateManagement")
        {
            LoadSave();
        }
    }
        //加载场景成功的回调
        private void OnLoadSceneSuccess(object sender, GameFramework.Scene.LoadSceneSuccessEventArgs e)
        {
            m_MainCamera = Camera.main;                                                    //获取主相机
            if (SceneManager.GetActiveScene() == m_GFScene)                                //如果当前是框架所在场景
            {
                Scene scene = SceneManager.GetSceneByName(GetSceneName(e.SceneAssetName)); //获取加载成功的场景
                if (!scene.IsValid())                                                      //加载的场景不合法
                {
                    Log.Error("[SceneComponent.OnLoadSceneSuccess] Loaded scene '{0}' is invalid.", e.SceneAssetName);
                    return;
                }

                SceneManager.SetActiveScene(scene); //激活场景
            }

            if (m_EnableLoadSceneSuccessEvent)
            {
                m_EventComponent.Fire(this, ReferencePool.Acquire <LoadSceneSuccessEventArgs>().Fill(e));
            }
        }
示例#26
0
        private void OnLoadSceneSuccess(object sender, GameFramework.Scene.LoadSceneSuccessEventArgs e)
        {
            m_MainCamera = Camera.main;
            if (SceneManager.GetActiveScene() == m_GameFrameworkScene)
            {
                Scene scene = SceneManager.GetSceneByName(GetSceneName(e.SceneAssetName));
                if (!scene.IsValid())
                {
                    Log.Error("Loaded scene '{0}' is invalid.", e.SceneAssetName);
                    return;
                }

                SceneManager.SetActiveScene(scene);
            }

            if (m_EnableLoadSceneSuccessEvent)
            {
                _eventComponent.Fire(this, ReferencePool.Acquire <LoadSceneSuccessEventArgs>().Fill(e));
            }
        }
示例#27
0
    // Start is called before the first frame update
    void Start()
    {
        globalObject = GameObject.Find("GlobalObject");
        if (UnitySceneManager.GetActiveScene().name == "SchnapHouse" && GameObject.Find("GlobalObject").GetComponent <GlobalControl>().items.Length == 0)
        {
            Invoke("PlaySchnap", 1);
        }



        if (GameObject.Find("GlobalObject").GetComponent <GlobalControl>().killedSchnap)
        {
            Destroy(GameObject.Find("Audio"));
        }

        if (UnitySceneManager.GetActiveScene().name == "SchnapHouse" && GameObject.Find("GlobalObject").GetComponent <GlobalControl>().killedSchnap)
        {
            GameObject.Find("Switch").SetActive(false);
        }
    }
示例#28
0
    private void Update()
    {
        // if game over true reset the game and update it //
        if (Gameover)
        {
            if (Input.anyKeyDown)
            {
                Time.timeScale = 1;
                SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
            }
            return;
        }
        if (!plyaed)              // if we didnt press any key dont play //
        {
            if (Input.anyKeyDown) // if we press key start game //
            {
                audioSource.Play();
                plyaed = true;
                ObstacleSoawner.Instance.playing = true;
                gravityvalue -= firstjumpvalue; //jumping //
                UlManeger.Instance.PlayGame();
            }
            return;
        }
        gravityvalue += gravityspeed * Time.deltaTime;
        tr.position  += Vector3.down * gravityvalue * Time.deltaTime;// virus go down //
        if (Input.anyKeyDown)
        {
            audioSource.Play();
            gravityvalue = -jumpvalue;                                   // if you pres key virus go up //
        }
        if (tr.position.y > limitscreen || tr.position.y < -limitscreen) // if virus go out of screen retunr game //

        {
            OutofScreenDanger();
        }
    }
示例#29
0
 private void ResetScene()
 {
     Scene.LoadScene(Scene.GetActiveScene().buildIndex);
 }
示例#30
0
    public void ReloadScene()
    {
        Scene currentScene = UnitySceneManager.GetActiveScene();

        UnitySceneManager.LoadScene(currentScene.name);
    }