private void MarkSceneAsLoaded(SceneField scene, bool isActive)
 {
     if (scene != null)
     {
         loadedScenes[scene] = isActive;
     }
 }
    /// <summary>
    /// Loads all Scenes informed (if the Scene is already loaded, nothing happens). After it, all other Scenes are unloaded.
    /// </summary>
    /// <param name="visibleScenes">Scenes that need to be visible. Scenes that are not loaded yet will be loaded.</param>
    /// <param name="activeScene">Set the Scene as active (The active Scene is the Scene which will be used as the target for new GameObjects instantiated by scripts and from what scene the lighting settings are used).</param>
    /// <param name="unloadOthers">If true, all managed Scenes that are not contained on visibleScenes will be unloaded.</param>
    public void Load(SceneField[] visibleScenes, SceneField activeScene = null, bool unloadOthers = true)
    {
        for (int i = 0; i < visibleScenes.Length; i++)
        {
            if (IsSceneLoaded(visibleScenes[i]) == false)
            {
                Load(visibleScenes[i]);
            }
        }

        if (activeScene != null && activeScene.SceneName != "")
        {
            if (IsSceneLoaded(activeScene))
            {
                SetActiveScene(activeScene);
            }
            else
            {
                Load(activeScene, setActiveScene: true);
            }
        }

        if (unloadOthers)
        {
            UnloadAllNonVisible(visibleScenes);
        }
    }
 void OnSceneChange(SceneField aScene)
 {
     if (!sequencedMusic)
     {
         PlaySceneMusic(aScene.SceneName);
     }
 }
Esempio n. 4
0
    IEnumerator LoadAsynchronously(SceneField scene, float delay)
    {
        Debug.Log("Loading the scene: " + scene);
        asyncOp = SceneManager.LoadSceneAsync(scene, LoadSceneMode.Single);
        asyncOp.allowSceneActivation = false;

        LoadSceneManager.bufferLoad = null;

        yield return(new WaitForSeconds(delay));

        while (!asyncOp.isDone)
        {
            if (asyncOp.progress < 0.9f)
            {
                if (view != null)
                {
                    view.UpdateUI(Mathf.Clamp01(asyncOp.progress / 0.9f));
                    yield return(null);
                }
            }
            else
            {
                if (view != null)
                {
                    view.UpdateUI(1);
                }
                yield return(new WaitForSeconds(delay));

                asyncOp.allowSceneActivation = true;
            }
            yield return(null);
        }
    }
Esempio n. 5
0
        public void Awake()
        {
            On.RoR2.Run.Start += (orig, self) =>
            {
                orig(self);
                SceneField sc = new SceneField("bazaar");
                NetworkManager.singleton.ServerChangeScene(sc);
                isFirstBazaarVisit = true;
                isFirstStage       = true;
            };

            //On.RoR2.BazaarController.Start += (orig, self) =>
            On.RoR2.SceneDirector.Start += (orig, self) =>
            {
                if (NetworkServer.active)
                {
                    if (Run.instance.stageClearCount == 0)
                    {
                        if (isFirstBazaarVisit && SceneManager.GetActiveScene().name.Contains("bazaar"))
                        {
                            GiveMoneyToPlayers(-(int)Run.instance.ruleBook.startingMoney);
                            isFirstBazaarVisit = false;
                        }
                        else if (isFirstStage)
                        {
                            GiveMoneyToPlayers((int)Run.instance.ruleBook.startingMoney);
                            isFirstStage = false;
                        }
                    }
                }
                orig(self);
            };
        }
Esempio n. 6
0
 public void LoadScene(SceneField aScene)
 {
     SceneManager.LoadScene(aScene);
     if (onNewSceneLoading != null)
     {
         onNewSceneLoading.Invoke(aScene);
     }
 }
Esempio n. 7
0
 public static void LoadScene(SceneField scene)
 {
     if (bufferLoad == null)
     {
         bufferLoad = scene;
         Instance.StartCoroutine(Instance.Init());
     }
 }
 /// <summary>
 /// Unloads the Scene.
 /// </summary>
 /// <param name="scene">Scene to be unloaded.</param>
 public void Unload(SceneField scene)
 {
     if (IsSceneLoaded(scene))
     {
         MarkSceneAsLoaded(scene, false);
         Unload(scene.SceneName);
     }
 }
Esempio n. 9
0
 public virtual void initGameLobby(string gameTittle, Sprite gameSprite, GameType type, SceneField scene)
 {
     gameObject.SetActive(true);
     initUserPanel();
     loginTCPUI.startServerClicked(true);
     setReadyButtons();
     gameImage.sprite = gameSprite;
     this.scene       = scene;
 }
Esempio n. 10
0
 void Start()
 {
     if (Instance != null)
     {
         Destroy(gameObject);
     }
     Instance = this;
     DontDestroyOnLoad(gameObject);
     actualScene = startScene;
 }
Esempio n. 11
0
 private bool CheckSceneLoadedScene(SceneField scene)
 {
     if (SceneManagerExtensions.IsSceneLoaded(scene))
     {
         Debug.LogWarning($"Scene {scene.SceneName} is already loaded... Skipping");
         return(true);
     }
     Debug.LogWarning($"Scene {scene.SceneName} is not loaded... Loading");
     return(false);
 }
Esempio n. 12
0
    public void AddSceneToBuild(SceneField inputScene)
    {
        {
            string[] fullFilePath0    = Directory.GetFiles(Application.dataPath, inputScene.SceneName + ".unity", SearchOption.AllDirectories);
            string   pathOfSceneToAdd = "Assets" + fullFilePath0[0].Substring(Application.dataPath.Length);

            //Loop through and see if the scene already exist in the build settings
            int indexOfSceneIfExist = -1;
            for (int i = 0; i < EditorBuildSettings.scenes.Length; i++)
            {
                Debug.Log("path : " + EditorBuildSettings.scenes[i].path);
                if (EditorBuildSettings.scenes[i].path == pathOfSceneToAdd)
                {
                    indexOfSceneIfExist = i;
                    break;
                }
            }

            EditorBuildSettingsScene[] newScenes;

            if (indexOfSceneIfExist == -1)
            {
                newScenes = new EditorBuildSettingsScene[EditorBuildSettings.scenes.Length + 1];

                //Seems inefficent to add scene to build settings after creating each scene (rather than doing it all at once
                //after they are all created, however, it's necessary to avoid memory issues.
                int i = 0;
                for (; i < EditorBuildSettings.scenes.Length; i++)
                {
                    newScenes[i] = EditorBuildSettings.scenes[i];
                }

                newScenes[i] = new EditorBuildSettingsScene(pathOfSceneToAdd, true);
            }
            else
            {
                newScenes = new EditorBuildSettingsScene[EditorBuildSettings.scenes.Length];

                int i = 0, j = 0;
                for (; i < EditorBuildSettings.scenes.Length; i++)
                {
                    //skip over the scene that is a duplicate
                    //this will effectively delete it from the build settings
                    if (i != indexOfSceneIfExist)
                    {
                        newScenes[j++] = EditorBuildSettings.scenes[i];
                    }
                }
                newScenes[j] = new EditorBuildSettingsScene(pathOfSceneToAdd, true);
            }

            EditorBuildSettings.scenes = newScenes;
        }
    }
Esempio n. 13
0
 public void CopySceneListFromBuild()
 {
     Scenes = new SceneField[EditorBuildSettings.scenes.Length];
     for (int i = 0; i < EditorBuildSettings.scenes.Length; ++i)
     {
         var        sceneBuildSetting = EditorBuildSettings.scenes[i];
         SceneAsset sceneAsset        = (SceneAsset)AssetDatabase.LoadAssetAtPath(sceneBuildSetting.path, typeof(SceneAsset));
         Scenes[i]            = new SceneField();
         Scenes[i].sceneAsset = sceneAsset;
     }
 }
    /// <summary>
    /// Loads the Scene.
    /// </summary>
    /// <param name="scene">Scene to be loaded</param>
    /// <param name="setActiveScene">If true, the Scene will be set as active (The active Scene is the Scene which will be used as the target for new GameObjects instantiated by scripts and from what scene the lighting settings are used).</param>
    public void Load(SceneField scene, bool setActiveScene = false)
    {
        MarkSceneAsLoaded(scene, true);
        var asyncOperation = SceneManager.LoadSceneAsync(scene.SceneName, LoadSceneMode.Additive);

        asyncOperation.allowSceneActivation = true;

        if (setActiveScene)
        {
            asyncOperation.completed += a => SetActiveScene(scene);
        }
    }
 /// <summary>
 /// Loads a stage.
 /// </summary>
 /// <param name="stage">The sage to load.</param>
 public static void LoadStage(SceneField stage)
 {
     if (WorldManager.UnlockedStages.Contains(stage))
     {
         StageManager = null;
         Debug.Log("Loading stage: " + stage);
         WorldManager.SetLastStage(stage);
         GameManager.Instance.onStage = true;
         GameManager.Instance.InitializeStageEntityManagers();
         SceneManager.LoadScene(stage);
     }
 }
Esempio n. 16
0
        private IEnumerator LoadSceneAsync(SceneField scene)
        {
            AsyncOperation async = SceneManager.LoadSceneAsync(scene, LoadSceneMode.Additive);

            while (async.progress < .9f)
            {
                yield return(null);
            }

            async.allowSceneActivation = true;
            OnSceneLoaded.Raise();
        }
Esempio n. 17
0
    IEnumerator LoadAndStartFirstLevel(SceneField _scene)
    {
        //curtain.Play("startround");
        AsyncOperation asyncLoadLevel = SceneManager.LoadSceneAsync(_scene, LoadSceneMode.Single);

        while (!asyncLoadLevel.isDone)
        {
            print("Loading the Scene");
            yield return(null);
        }
        LoadLevelData();
        queue.RemoveAt(0);
        StartRound();
    }
Esempio n. 18
0
    /// <summary>
    /// Randomize each unsolved configuration.
    /// </summary>
    public void Randomize()
    {
        Debug.Assert(game_modes.Length > 0, "No supported game mode.");
        Debug.Assert(arenas.Length > 0, "No supported arena.");

        if (game_mode == null)
        {
            game_mode = game_modes[UnityEngine.Random.Range(0, game_modes.Length)];
        }

        if (!arena.IsValid)
        {
            arena = arenas[UnityEngine.Random.Range(0, arenas.Length)];
        }
    }
Esempio n. 19
0
    IEnumerator LoadLevel(SceneField scene, bool loadData = false)
    {
        AsyncOperation asyncLoadLevel = SceneManager.LoadSceneAsync(scene.SceneName, LoadSceneMode.Single);

        isLoading = true;
        while (!asyncLoadLevel.isDone)
        {
            print("Loading the Scene");
            yield return(null);
        }
        if (loadData)
        {
            LoadLevelData();
        }
        isLoading = false;
    }
Esempio n. 20
0
 // Update is called once per frame
 void Update()
 {
     if (proxScene == gameoverScene && actualScene != gameoverScene && life <= 0)
     {
         actualScene = gameoverScene;
         SceneManager.LoadScene(proxScene, LoadSceneMode.Single);
         source.Stop();
         source.PlayOneShot(gameoverSound, 1.0f);
     }
     if (proxScene == gameScene && actualScene != gameScene)
     {
         actualScene = gameScene;
         SceneManager.LoadScene(proxScene, LoadSceneMode.Single);
         source.clip = gameSound;
         source.Play();
     }
 }
Esempio n. 21
0
 IEnumerator showAdThenNext(SceneField scene)
 {
     if (Advertisement.isSupported && Advertisement.isInitialized && Advertisement.IsReady())
     {
         //stop audio
         float volume = AudioListener.volume;
         AudioListener.volume = 0;
         //show ad
         Advertisement.Show();
         while (Advertisement.isShowing)
         {
             yield return(null);               //wait until the user finishes up with this ad
         }
         //restart audio
         AudioListener.volume = volume;
     }
     SceneManager.LoadScene(scene);
 }
Esempio n. 22
0
    public static void MoveObjectToScene(GameObject go, SceneField targetScene)
    {
        if (targetScene.SceneName.Length < 1)
        {
            return;
        }
        Scene s = SceneManager.GetSceneByName(targetScene.SceneName);

        Debug.Log(s);
        if (s != null)
        {
            SceneManager.MoveGameObjectToScene(go, s);
            SaveObjManager.MoveItem(go, targetScene.SceneName, go.transform.position);
        }
        else
        {
            SaveObjManager.MoveItem(go, targetScene.SceneName, go.transform.position);
            Destroy(go);
        }
    }
Esempio n. 23
0
    public void RestoreState()
    {
        stage             = Stage.SortClips1;
        selectedSlotIndex = -1;
        currentClip       = 0;

        editorScene          = storedState.editorScene;
        getClipScene         = storedState.getClipScene;
        videoTransitionScene = storedState.videoTransitionScene;

        for (int i = 0; i < videoSlots.Length; ++i)
        {
            videoSlots[i].sprite = storedState.videoSlots[i].sprite;
            videoSlots[i].active = storedState.videoSlots[i].active;
            videoSlots[i].scene  = storedState.videoSlots[i].scene;
            videoSlots[i].order  = storedState.videoSlots[i].order;
            videoSlots[i].tag    = storedState.videoSlots[i].tag;
        }

        for (int i = 0; i < candles.Length; ++i)
        {
            candles[i] = storedState.candles[i];
        }
    }
Esempio n. 24
0
        void OnGUI()
        {
            EditorGUILayout.BeginVertical();
            {
                if (GUILayout.Button("Refresh"))
                {
                    var favoriteGUIDs = AssetDatabase.FindAssets("t:SceneFavoritesAsset");
                    favoritesAssets = favoriteGUIDs.Select(s =>
                                                           AssetDatabase.LoadAssetAtPath <SceneFavoritesAsset>(AssetDatabase.GUIDToAssetPath(s))).ToList();
                    return;
                }

                EditorGUILayout.Separator();

                if (favoritesAssets == null)
                {
                    return;
                }

                foreach (var favoritesAsset in favoritesAssets)
                {
                    EditorGUILayout.LabelField(favoritesAsset.name);


                    EditorGUI.indentLevel++;
                    foreach (var favorite in favoritesAsset.favorites)
                    {
                        EditorGUILayout.LabelField(favorite.name);

                        EditorGUILayout.LabelField(string.Join("|", favorite.scenes.Select(field => { field.Fix();
                                                                                                      return(field.SceneName); }).ToArray()));

                        EditorGUILayout.BeginHorizontal();
                        {
                            bool load    = false;
                            bool aditive = false;
                            if (GUILayout.Button("Load"))
                            {
                                load = true;
                            }

                            if (GUILayout.Button("Load Additive"))
                            {
                                load    = true;
                                aditive = true;
                            }

                            if (load)
                            {
                                var scenes = SolveAllScenes(favorite);
                                Load(scenes, aditive);
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    EditorGUI.indentLevel--;

                    EditorGUILayout.Separator();

                    if (GUILayout.Button("AddActiveAsFavorite"))
                    {
                        var activeScenePath = EditorSceneManager.GetActiveScene().path;
                        var activeSceneGUID = AssetDatabase.AssetPathToGUID(activeScenePath);
                        var sceneField      = SceneField.CreateFromGUID(activeSceneGUID);
                        sceneField.Fix();
                        favoritesAsset.favorites.Add(new SceneFavoritesAsset.SceneFavorite
                        {
                            name   = sceneField.SceneName,
                            scenes = new List <SceneField> {
                                sceneField
                            }
                        });
                        this.Repaint();
                        return;
                    }


                    EditorGUILayout.Separator();
                }
            }
            EditorGUILayout.EndVertical();
        }
Esempio n. 25
0
    public void SetNewScene(SceneField scene)
    {
        sceneNetworkManger.onlineScene = scene.SceneName.Remove(0, 7);;

        UpdateSelectedMapName();
    }
 /// <summary>
 /// Sets the Scene as active (The active Scene is the Scene which will be used as the target for new GameObjects instantiated by scripts and from what scene the lighting settings are used).
 /// </summary>
 /// <param name="scene"></param>
 private void SetActiveScene(SceneField scene)
 {
     SceneManager.SetActiveScene(SceneManager.GetSceneByName(scene.SceneName));
 }
Esempio n. 27
0
        // Use this for initialization
        void Start()
        {
            if (VRTracker.Manager.VRT_Manager.Instance.spectator)
            {
                gameObject.SetActive(false);
                if (gameScene != null)
                {
                    if (SceneManager.GetActiveScene().name != gameScene.SceneName.Split('/')[gameScene.SceneName.Split('/').Length - 1])
                    {
                        SceneManager.LoadScene(gameScene);
                    }
                }
                else if (SceneManager.GetActiveScene().name != gameScene.SceneName.Split('/')[gameScene.SceneName.Split('/').Length - 1])
                {
                    Debug.LogWarning("Could not load Game Scene in Spectator mode as the Game Scene is not linked in VRT_PairingManager");
                }
                return;
            }
            else
            {
                DontDestroyOnLoad(this);
            }

            SceneManager.sceneLoaded += OnSceneLoaded;
            VRTracker.Manager.VRT_Manager.Instance.OnAvailableTag += AddAvailableTag;

            if (pairingUI == null)
            {
                pairingUI = GetComponent <VRT_PairingUI>();
            }
            if (pairingUI == null)
            {
                pairingUI = GetComponent <VRT_PairingUIStandardAssets>();
            }


            // If we couldn't find the Pairing UI on Start, it means we did not started from the Pairing scene, but the Main Scene
            // So we need to save the information
            if (pairingUI == null)
            {
                if (gameScene == null)
                {
                    gameScene = new SceneField(SceneManager.GetActiveScene());
                }

                StartCoroutine(PairFromMainScene());
            }

            // Started from the pairing scene
            else
            {
                pairingScene = new SceneField(SceneManager.GetActiveScene());
                Debug.Log("Type Of Pairing Scene " + pairingScene.GetType().ToString());
                if (VRTracker.Manager.VRT_Manager.Instance.spectator)
                {
                    if (gameScene.SceneName != "")
                    {
                        SceneManager.LoadScene(gameScene);
                    }
                    else // Load next scene in Build setting if no Game Scene was set manually in the Pairing Manager
                    {
                        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
                    }
                }
                // Not spectator
                else
                {
                    StartCoroutine(Pair());
                }
            }
        }
Esempio n. 28
0
 void OnNewSceneLoading(SceneField aScene)
 {
     MouseCursor.instance.SetCursor(MouseCursor.instance.defaultCursor);
     GameHandler.persistencyManager.SetUnlockedState(this);
 }
Esempio n. 29
0
 public void SelectDefeatNextScene()
 {
     selectedNextScene = defeatNextScene;
     screenFaderManager.StartFadeToBlack();
 }
Esempio n. 30
0
 public void SelectVictoryNextScene()
 {
     selectedNextScene = victoryNextScene;
     screenFaderManager.StartFadeToBlack();
 }