Пример #1
0
        private static void UnitySceneManagerLoaded(Scene scene, LoadSceneMode mode)
        {
            TCScene tcScene = FindSceneInfo(scene.name);

            if (tcScene == null)
            {
                return;
            }

            OnSceneLoadedEvent?.Invoke(tcScene);
        }
Пример #2
0
        /// <summary>
        ///     Loads a scene
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="loadMode"></param>
        /// <returns></returns>
        public static AsyncOperation LoadScene(TCScene scene, LoadSceneMode loadMode = LoadSceneMode.Single)
        {
            PreparingSceneLoadEvent?.Invoke(scene);
            Debug.Log($"The scene `{scene.scene}` was requested to be loaded.");

            AsyncOperation sceneLoad = SceneManager.LoadSceneAsync(scene.scene, loadMode);

            StartSceneLoadEvent?.Invoke(sceneLoad);

            return(sceneLoad);
        }
Пример #3
0
        public static void LoadSceneCommand(string[] args)
        {
            NetworkManagerMode mode = NetworkManager.singleton.mode;

            TCScene scene = FindSceneInfo(args[0]);

            //Scene doesn't exist
            if (scene == null)
            {
                Logger.Error("The scene '{@Scene}' doesn't exist!", args[0]);
                return;
            }

            //This scene cannot be loaded to
            if (!scene.canLoadTo)
            {
                Logger.Error("You cannot load to this scene!");
                return;
            }

            switch (mode)
            {
            //We are in client mode
            case NetworkManagerMode.ClientOnly:
                //Disconnect from current server
                NetworkManager.singleton.StopHost();

                //Load the scene
                Logger.Info("Changing scene to {@Scene}...", scene.scene);
                LoadScene(scene);
                break;

            //We are server, so we will tell the server and clients to change scene
            case NetworkManagerMode.ServerOnly:
                Logger.Info("Changing scene to {@Scene}...", scene.scene);
                NetworkManager.singleton.ServerChangeScene(scene.scene);
                break;

            case NetworkManagerMode.Offline:
                Logger.Info("Changing scene to {@Scene}...", scene.scene);
                LoadScene(scene);
                break;
            }
        }