Example #1
0
        public static void ExportPackages()
        {
            CoreLogger.LogDebug("PackageManager", "parsing command line");

            CommandLineParser cmdParser = new CommandLineParser();

            string filename = cmdParser["filename"];

            if (filename != null)
            {
                CoreLogger.LogDebug("PackageManager", string.Format("export manifest specified to be {0}", filename));
            }
            else
            {
                CoreLogger.LogDebug("PackageManager", "export manifest specified to be the default exports.xml");
                filename = "exports.xml";
            }

            string outputPath = cmdParser["outputpath"];

            if (outputPath != null)
            {
                CoreLogger.LogDebug("PackageManager", string.Format("output path set to be {0}", outputPath));
            }
            else
            {
                CoreLogger.LogDebug("PackageManager", "output path set to be the default");
            }

            ExportPackages(filename, outputPath);
        }
Example #2
0
        //FIXME queue all scene switches, whether additive or not, as tasks

        /// <summary>
        /// Switches to the scene specified by newScene. The sequence of operation is:
        /// first the current scene receives a notification that it is about to be unloaded.
        /// It then has time to prepare and do whatever it needs, until the timeout passes,
        /// or it signals that it is ready by setting its ReadyToUnload flag to true.
        /// Once either happens, the old scene receives a SceneClosing notification,
        /// and the loading of the new scene begins.
        /// Note that Unity does not guaranteee anything concerning the actual time it
        /// takes to load/unload a scene - once the call to LoadLeve is made, the scenes
        /// should consider themselves to be in Limbo and presume nothing.
        /// </summary>
        /// <param name="newScene">Name of the new scene to switch to.</param>
        /// <param name="handovers">If passed, contains a collection of objects that will
        /// be preserved for passing on to the next scene </param>
        public void SwitchScene(string newScene, IEnumerable <IEnumerableAction> preloadActions)
        {
            string realScene = _sceneMapping[newScene];

            CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("requested scene {0} (mapped to {1})", newScene, realScene));

            SceneRequested(realScene);

            GetLoader(realScene, defaultSceneTransition, preloadActions).Start();
        }
        void OnLevelLoaded(int level)
        {
            float loadTime   = Time.realtimeSinceStartup - _levelLoadStart;
            int   loadFrames = Time.frameCount - _levelLoadStartFrame;

            _levelLoadStart      = -1f;
            _levelLoadStartFrame = -1;

            CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("requested scene {0} was loaded; loading took {1} seconds and {2} frames", _sceneName, loadTime, loadFrames));
        }
        override protected void Awake()
        {
            base.Awake();

            if (s_activeControllers.Count > 0)
            {
                if (s_activeControllers.FirstOrDefault(c => c.SceneName == SceneName) != null)
                {
                    CoreLogger.LogWarning(LoggerModules.SceneManager, string.Format("scene controller with name {0} already active!", SceneName));
                }
                else
                {
                    CoreLogger.LogWarning(LoggerModules.SceneManager, string.Format("scene controller {0} awakening while there are other active controllers!", SceneName));
                }
            }

            s_activeControllers.Add(this);

            CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("scene controller for scene {0} awakening and setting itself current instead of {1}",
                                                                          SceneName, s_current.Target == null ? "null" : s_current.Target.SceneName));
            s_current.Target = this;

#if UNITY_EDITOR
            //a testing scene would not be a part of the build
            if (sceneType == SceneType.Testing)
            {
                if (s_jumpToInitOnTestScenes)
                {
                    s_jumpToInitOnTestScenes = false;
                    string temp = forceInitScene;
                    forceInitScene = "";
                    GameApplication.RequestingScene = Application.loadedLevelName;
                    Application.LoadLevel(temp);
                    return;
                }
            }

            if (Application.loadedLevel != 0 && GameApplication.RequestingScene == "")
            {
                GameApplication.RequestingScene = Application.loadedLevelName;

                if (forceInitScene != "")
                {
                    Application.LoadLevel(forceInitScene);
                }
                else
                {
                    Application.LoadLevel(0);
                }
            }
#endif
        }
        public void OnSceneClosing()
        {
            if (_readyToUnload)
            {
                CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("scene {0} received SceneClosing", SceneName));
            }
            else
            {
                CoreLogger.LogWarning(LoggerModules.SceneManager, string.Format("scene {0} received SceneClosing without being ready!", SceneName));

                //FIXME: better terminate all exits and stuff?
            }
        }
Example #6
0
        protected override void OnActivate()
        {
            Debugger.Assert(_stage == Stage.Inactive, "Activated twice!");

            _now = Time.time;
            CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("{0} activated!", name));

            base.OnActivate();

            DontDestroyOnLoad(this);

            _stage = Stage.Out;

            StartCoroutine("TransitionOut");
        }
        IEnumerator Init()
        {
            float startTime  = Time.realtimeSinceStartup;
            int   startFrame = Time.frameCount;

            IEnumerable <ISceneEntry> entries = GetComponentsInChildren(typeof(ISceneEntry)).Cast <ISceneEntry>()
                                                .Concat(_pendingEntries);

            CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("scene {0} Starting Init with {1} scene entries", SceneName, entries.Count()));

            //make sure all scene initializations are done
            _inEntry = true;
            while (_inEntry)
            {
                bool entering = false;
                foreach (ISceneEntry entry in entries)
                {
                    if (!entry.Done)
                    {
                        entering = true;
                        break;
                    }
                }

                _inEntry = entering;

                yield return(null);
            }

            _readyToRun = true;

            _resourceLibraries = GetComponentsInChildren(typeof(IResourceLibrary)).Cast <IResourceLibrary>().ToList();

            _inEntry = false;
            _pendingEntries.Clear();

            if (handleBackButton && GameApplication.Instance != null)
            {
                SubscribeToBackButtonEvent();
            }

            SceneStarted();

            CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("Init Done - took {0} seconds, {1} frames", Time.realtimeSinceStartup - startTime, Time.frameCount - startFrame));
        }
Example #8
0
        private static void ExportPackages(string moduleFilename, string outputPath)
        {
            if (!File.Exists(moduleFilename))
            {
                CoreLogger.LogError("PackageManager", string.Format("unable to find file {0}", moduleFilename));
                return;
            }

            CoreLogger.LogDebug("PackageManager", string.Format("beginning export of package in file {0}", moduleFilename));

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(moduleFilename);

            if (xmlDoc.DocumentElement.Name != "module")
            {
                CoreLogger.LogError("PackageManager", string.Format("error in file {0}: root element of module file should be module!", moduleFilename));
                return;
            }

            if (!xmlDoc.DocumentElement.HasAttribute("packageName"))
            {
                CoreLogger.LogError("PackageManager", string.Format("error in file {0}: module element missing packageName attribute!", moduleFilename));
                return;
            }

            string packageName     = xmlDoc.DocumentElement.GetAttribute("packageName");
            string packageFilename = string.Format("{0}{1}{2}.unitypackage", outputPath, System.IO.Path.DirectorySeparatorChar, packageName);

            string[] folders = xmlDoc.DocumentElement.GetElementsByTagName("folder").Cast <XmlElement>().Where(e => e.HasAttribute("name")).Select(
                e => string.Format("Assets{0}{1}", System.IO.Path.DirectorySeparatorChar, e.GetAttribute("name"))).ToArray();

            foreach (string folder in folders)
            {
                CoreLogger.LogDebug("PackageManager", string.Format("including folder {0} and all its subfolders", folder));
            }

            CoreLogger.LogDebug("PackageManager", string.Format("exporting {0} folders to file {1}", folders.Length, packageFilename));

            AssetDatabase.ExportPackage(folders, packageFilename, ExportPackageOptions.Recurse);

            CoreLogger.LogDebug("PackageManager", "done!");
        }
Example #9
0
        public T GetResource <T> (string path, bool isCascading) where T : Object
        {
            float startTime = Time.realtimeSinceStartup;

            //if there is no catalog, or if there is and we cannot find the bundle name,
            //or if we can and the bundle is not in the cache,
            //just try and load the plain old Unity way

            string bundleName = "";

            if (_catalog != null)
            {
                bundleName = _catalog[path]["bundle"];
            }

            AssetBundle bundle = null;

            if (bundleName != null)
            {
                bundle = GetBundle(path);
            }

            T resource;

            if (bundle == null)
            {
                CoreLogger.LogDebug(_loggerModule, string.Format("unable to obtain bundle {0} from cache; loading {1} locally in {2} seconds",
                                                                 bundleName, path, Time.realtimeSinceStartup - startTime));
                try
                {
                    resource = Resources.Load <T>(path);
                } catch
                {
                    return(null);
                }

                return(resource);
            }

            resource = bundle.LoadAsset(path) as T;
            CoreLogger.LogDebug(_loggerModule, string.Format("resource {0} requested immediately, loaded from bundle {1} in {2} seconds", path, bundleName, Time.realtimeSinceStartup - startTime));
            return(resource);
        }
Example #10
0
        public ISceneLoaderTask GetLoader(string sceneName, SceneTransition sceneTransition = null, IEnumerable <IEnumerableAction> preloadActions = null)
        {
            if (sceneTransition == null)
            {
                sceneTransition = defaultSceneTransition;
            }

            ISceneLoaderTask task = new SceneLoaderTask(this, sceneName, sceneTransition, preloadActions);

            task.Done += result => {
                if (result.IsOk())
                {
                    CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("loaded scene {0}", sceneName));
                    SceneLoaded(sceneName);
                }
            };

            return(task);
        }
        IEnumerator Terminate()
        {
            float startTime  = Time.realtimeSinceStartup;
            int   startFrame = Time.frameCount;

            IEnumerable <ISceneExit> exits = GetComponentsInChildren(typeof(ISceneExit)).Cast <ISceneExit>()
                                             .Concat(_pendingExits);

            CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("scene {0} Starting Terminate with {1} exits", SceneName, exits.Count()));

            UnSubscribeFromBackButtonEvent();

            yield return(GameApplication.Instance.CoroutineFactory.StartCoroutine(EnumerableAction.Parallelize(exits.Select(e => e.ExitSequence))));

            _readyToUnload = true;
            _inExit        = false;
            _pendingExits.Clear();

            CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("Terminate Done in {0} seconds, {1} frames", Time.realtimeSinceStartup - startTime, Time.frameCount - startFrame));
        }
Example #12
0
        IEnumerator Load()
        {
            reactivate = true;

            Deactivate();

            float startRealtime = Time.realtimeSinceStartup;
            float startGametime = Time.time;
            int   startFrame    = Time.frameCount;

            ISceneLoadAction[] actions = GetComponentsInChildren(typeof(ISceneLoadAction)).Cast <ISceneLoadAction>().ToArray();
            float total = actions.Length + 1;
            float done  = 0;

            CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("SceneLoader beginning {0} actions...", actions.Length));

            foreach (ISceneLoadAction action in GetComponentsInChildren(typeof(ISceneLoadAction)))
            {
                float actionStart      = Time.realtimeSinceStartup;
                int   actionFrameStart = Time.frameCount;
                yield return(GameApplication.Instance.CoroutineFactory.StartCoroutine(action.Action));

                CoreLogger.LogInfo(LoggerModules.SceneManager, string.Format("performed load action {0} in {1} seconds and {2} frames",
                                                                             action.Name, Time.realtimeSinceStartup - actionStart, Time.frameCount - actionFrameStart));

                done     += 1;
                _progress = done / total;

                CoreLogger.LogInfo(LoggerModules.SceneManager, string.Format("progress is {0} ({1}/{2})", _progress, done, total));
            }

            CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("beginning to proxy-load scene {0}, actions took {1} seconds real time, {2} seconds game time, {3} frames",
                                                                          realScene, Time.realtimeSinceStartup - startRealtime, Time.time - startGametime, Time.frameCount - startFrame));
            startRealtime = Time.realtimeSinceStartup;
            startGametime = Time.time;
            startFrame    = Time.frameCount;

            while (Time.realtimeSinceStartup - startRealtime < minimumTime)
            {
                yield return(null);
            }

            bool  loaded = false;
            ITask loader = GameApplication.Instance.SceneManager.GetAdditiveLoader(realScene, sceneTransition, cleanup ? removals : null);

            CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("starting additive loader {0}", loader.Name));
            loader.Start(result => {
                if (!result.IsOk())
                {
                    CoreLogger.LogError(LoggerModules.SceneManager, string.Format("failed to load scene {0}!", realScene));
                }
                else
                {
                    CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("done proxy-loading of scene {0}: took {1} seconds real-time, {2} game time, {3} frames",
                                                                                  realScene, Time.realtimeSinceStartup - startRealtime, Time.time - startGametime, Time.frameCount - startFrame));
                }
                loaded    = true;
                _progress = 1f;

                Reactivate();
            }, loadTimeout);

            while (!loaded)
            {
                float loaderProgress = loader.Progress;
                _progress = (done + loaderProgress) / total;

                CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("progress is {0} ({1}/{2}); loading progress is {3}; yielding...", _progress, done, total, loaderProgress));

                yield return(null);
            }
        }
Example #13
0
        public IEnumerator DownloadAndCache(string bundleName, System.Action <AssetBundle> handler, int version)
        {
            LoadedBundle loadedBundle;

            if (_bundles.TryGetValue(bundleName, out loadedBundle))
            {
                if (loadedBundle != null)
                {
                    if (loadedBundle.version == version)
                    {
                        loadedBundle.lastRequest = Time.time;
                        loadedBundle.numRequests++;
                        handler(loadedBundle.bundle);
                        yield break;
                    }
                }
            }

            // Wait for the Caching system to be ready
            while (!Caching.ready)
            {
                yield return(null);
            }

            if (!maintainBundleCache)
            {
#if UNITY_2017_1_OR_NEWER
                Caching.ClearCache();
#else
                Caching.CleanCache();
#endif
            }

            // Load the AssetBundle file from Cache if it exists with the same version or download and store it in the cache
            string bundleUrl = GetBundleUrl(bundleName);
            CoreLogger.LogInfo("BundleManager", string.Format("for bundle {0}, full url is {1}", bundleName, bundleUrl));
            using (WWW www = WWW.LoadFromCacheOrDownload(bundleUrl, version))
            {
                yield return(www);

                if (www.error != null)
                {
                    CoreLogger.LogWarning(name, string.Format("unable to retrieve bundle {0}:{1}", bundleUrl, www.error));
                    handler(null);
                    yield break;
                }

                CoreLogger.LogDebug("BundleManager", string.Format("successfully retrieved bundle {0} from {1}", bundleName, bundleUrl));

                if (loadedBundle != null)
                {
                    CoreLogger.LogDebug("BundleManager", string.Format("New version ({0}) of bundle {1} retrieved - unloading old version ({2}) and caching new one", version, bundleName, loadedBundle.version));
                    loadedBundle.bundle.Unload(false);
                    loadedBundle.bundle = www.assetBundle;
                }
                else
                {
                    CollectGarbage();

                    CoreLogger.LogDebug("BundleManager", string.Format("caching version {0} of bundle {1}", version, bundleName));
                    _bundles[bundleName] = new LoadedBundle()
                    {
                        bundle = www.assetBundle, version = version
                    };
                }

                handler(www.assetBundle);
            }
        }
        override protected IEnumerator Controller()
        {
            ISceneLoaderTask pending = _sceneManager.PendingLoadTask;

            if (pending != null)
            {
                if (pending.SceneName == _sceneName)
                {
                    CoreLogger.LogNotice(LoggerModules.SceneManager, string.Format("{0}: pending request for the same scene ({1}); ending operation", _name, _sceneName));
                    InvokeDone(TaskEnding.Done);
                    yield break;
                }
            }

            CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("setting pending load to additive loader: {0}", _name));
            _sceneManager.PendingLoadTask = this;

            if (pending != null)
            {
                CoreLogger.LogNotice(LoggerModules.SceneManager, string.Format("{0}: waiting on loader {1}...", _name, pending.Name));
                yield return(GameApplication.Instance.CoroutineFactory.Wait(pending));

                CoreLogger.LogNotice(LoggerModules.SceneManager, string.Format("{0}: waiting on loader {1} done!", _name, pending.Name));
            }

            CoreLogger.LogInfo(LoggerModules.SceneManager, string.Format("starting additive async load of scene {0}", _sceneName));
            _operation = Application.LoadLevelAdditiveAsync(_sceneName);
            _operation.allowSceneActivation = false;
            _operation.priority             = 0;

            while (_progress < _additiveLoaderWatermark)
            {
                if (_cancel)
                {
                    InvokeDone(TaskEnding.Cancelled);
                    yield break;
                }

                yield return(null);

                _lastProgress = _progress;
                _progress     = _operation.progress;

                if (_progress < _lastProgress)
                {
                    //time travel - this can happen if we came back from background
                    CoreLogger.LogNotice(LoggerModules.SceneManager, "time travel in scene loader - loading the next scene and calling done");
                }
            }

            _progress = 1;
            yield return(null);

            yield return(new WaitForSeconds(_delay));

            SceneTransition sceneTransition = null;

            if (_sceneTransition != null)
            {
                sceneTransition = _sceneTransition.gameObject.GetComponent <SceneTransition>();
                if (sceneTransition != null)
                {
                    GameObject newInstance = GameObject.Instantiate(_sceneTransition.gameObject) as GameObject;
                    GameObject.DontDestroyOnLoad(newInstance);

                    sceneTransition = newInstance.GetComponent <SceneTransition>();
                    Debugger.Assert(sceneTransition != null, "sceneTransition cannot be null!");
                    if (sceneTransition != null)
                    {
                        GameApplication.Instance.CoroutineFactory.StartCoroutine(sceneTransition.ExitSequence);

                        yield return(GameApplication.Instance.CoroutineFactory.StartCoroutine(sceneTransition.WaitForFadeout));
                    }
                }
            }

            CoreLogger.LogInfo(LoggerModules.SceneManager, string.Format("allowing scene additive load operation to complete"));

            _operation.allowSceneActivation = true;
            yield return(_operation);

            CoreLogger.LogInfo(LoggerModules.SceneManager, string.Format("done additive load of scene {0}", _sceneName));

            HandleRemovals();

            if (sceneTransition != null)
            {
                sceneTransition.OnLevelWasLoaded(Application.loadedLevel);
                CoreLogger.LogInfo(LoggerModules.SceneManager, string.Format("additive load of scene {0} will now handle transition {1}", _sceneName, sceneTransition.name));
                yield return(GameApplication.Instance.CoroutineFactory.StartCoroutine(sceneTransition.WaitForFadein));
            }

            if (_sceneManager.PendingLoadTask == this)
            {
                CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("resetting pending load from {0} to null", _name));
                _sceneManager.PendingLoadTask = null;
            }
            else
            {
                if (_sceneManager.PendingLoadTask == null)
                {
                    CoreLogger.LogError(LoggerModules.SceneManager, string.Format("{0}: pending load is null!", _name));
                }
                else
                {
                    CoreLogger.LogError(LoggerModules.SceneManager, string.Format("{0}: no need to reset pending since it is already somebody else: {1}", _name, _sceneManager.PendingLoadTask.Name));
                }
            }

            CoreLogger.LogInfo(LoggerModules.SceneManager, string.Format("additive load of scene {0} will now invoke done", _sceneName));
            InvokeDone(TaskEnding.Done);
            CoreLogger.LogInfo(LoggerModules.SceneManager, string.Format("additive load of scene {0} has invoked done", _sceneName));
        }
        public void PrepareToUnload()
        {
            CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("scene {0} received PrepareToUnload - calling Terminate", SceneName));

            StartCoroutine(Terminate());
        }
        override protected IEnumerator Controller()
        {
            ISceneLoaderTask pending = _sceneManager.PendingLoadTask;

            if (pending != null)
            {
                if (pending.SceneName == _sceneName)
                {
                    CoreLogger.LogNotice(LoggerModules.SceneManager, string.Format("{0}: pending request for the same scene ({1}); ending operation", _name, _sceneName));
                    InvokeDone(TaskEnding.Done);
                    yield break;
                }
            }

            CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("setting pending load to additive loader: {0}", _name));
            _sceneManager.PendingLoadTask = this;

            if (pending != null)
            {
                CoreLogger.LogNotice(LoggerModules.SceneManager, string.Format("{0}: waiting on loader {1}...", _name, pending.Name));
                yield return(GameApplication.Instance.CoroutineFactory.Wait(pending));

                CoreLogger.LogNotice(LoggerModules.SceneManager, string.Format("{0}: waiting on loader {1} done!", _name, pending.Name));
            }

            SceneTransition sceneTransition = null;

            if (_sceneTransition != null)
            {
                sceneTransition = _sceneTransition.gameObject.GetComponent <SceneTransition>();
                if (sceneTransition != null)
                {
                    GameObject newInstance = GameObject.Instantiate(_sceneTransition.gameObject) as GameObject;
                    GameObject.DontDestroyOnLoad(newInstance);

                    sceneTransition = newInstance.GetComponent <SceneTransition>();
                    Debugger.Assert(sceneTransition != null, "sceneTransition cannot be null!");
                    if (sceneTransition != null)
                    {
                        _sceneManager.HookTransition(sceneTransition);
                        GameApplication.Instance.CoroutineFactory.StartCoroutine(sceneTransition.ExitSequence);


                        yield return(GameApplication.Instance.CoroutineFactory.StartCoroutine(sceneTransition.WaitForFadeout));
                    }
                }
            }

            CoreLogger.LogInfo(LoggerModules.SceneManager, string.Format("starting additive sync load of scene {0}", _sceneName));
            Application.LoadLevelAdditive(_sceneName);
            CoreLogger.LogInfo(LoggerModules.SceneManager, string.Format("done additive load of scene {0}", _sceneName));

            HandleRemovals();

            if (sceneTransition != null)
            {
                sceneTransition.OnLevelWasLoaded(Application.loadedLevel);

                yield return(GameApplication.Instance.CoroutineFactory.StartCoroutine(sceneTransition.WaitForFadein));
            }

            if (_sceneManager.PendingLoadTask == this)
            {
                CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("resetting pending load from {0} to null", _name));
                _sceneManager.PendingLoadTask = null;
            }

            InvokeDone(TaskEnding.Done);
        }
 void OnDestroy()
 {
     CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("scene controller {0} going down!", SceneName));
     s_activeControllers.Remove(this);
 }
        override protected IEnumerator Controller()
        {
            ISceneLoaderTask pending = _sceneManager.PendingLoadTask;

            if (pending != null)
            {
                if (pending.SceneName == _sceneName)
                {
                    CoreLogger.LogNotice(LoggerModules.SceneManager, string.Format("{0}: pending request for the same scene ({1}); ending operation", _name, _sceneName));
                    InvokeDone(TaskEnding.Done);
                    yield break;
                }
            }

            CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("setting pending load to {0}", _name));
            _sceneManager.PendingLoadTask = this;

            if (pending != null)
            {
                CoreLogger.LogNotice(LoggerModules.SceneManager, string.Format("{0}: waiting on loader {1}...", _name, pending.Name));
                yield return(GameApplication.Instance.CoroutineFactory.Wait(pending));

                CoreLogger.LogNotice(LoggerModules.SceneManager, string.Format("{0}: waiting on loader {1} done!", _name, pending.Name));
            }

            float startTime = Time.realtimeSinceStartup;

            //check to see if the current scene has a TabTale controller (all scenes are supposed to have one)
            ISceneController currentSceneController = SceneController.Current;

            if (currentSceneController != null)
            {
                if (_sceneTransition != null)
                {
                    if (currentSceneController == null)
                    {
                        CoreLogger.LogNotice(LoggerModules.SceneManager, "no controller found in scene - injection of transitions is not possible!");
                    }
                    else
                    {
                        CoreLogger.LogInfo(LoggerModules.SceneManager, string.Format("injecting effect {0} into the scene", _sceneTransition.name));
                        InjectTransition(_sceneTransition, currentSceneController);
                    }
                }

                //tell the current scene it is about to be unloaded
                currentSceneController.PrepareToUnload();

                CoreLogger.LogInfo(LoggerModules.SceneManager, string.Format("{0}: waiting for current scene {1} to be ready to unload", _name, currentSceneController.SceneName));

                //async. waiting for either the old scene's signal that it's ready, or the timeout

                while (!currentSceneController.ReadyToUnload && (Time.realtimeSinceStartup - startTime <= _sceneManager.sceneUnloadTimeout))
                {
                    yield return(null);
                }

                CoreLogger.LogInfo(LoggerModules.SceneManager, string.Format("scene {0} done - wait took {1} seconds", currentSceneController.SceneName, Time.realtimeSinceStartup - startTime));

                //tell the current scene it is being unloaded
                currentSceneController.OnSceneClosing();
            }
            else
            {
                CoreLogger.LogWarning(LoggerModules.SceneManager, "Unable to find TabTale Scene Controller!");
            }

            _levelLoadStart      = Time.realtimeSinceStartup;
            _levelLoadStartFrame = Time.frameCount;

            if (_sceneManager.asyncPreloading)
            {
                yield return(_sceneManager.PreloadActions(_preloadActions));
            }
            else
            {
                _sceneManager.HandlePreloadActions(_preloadActions);
            }

            if (_sceneManager.asyncLoading && !Application.platform.IsEditor())
            {
                CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("Loading new scene {0} asynchronously...", _sceneName));

                SceneLoadStarted();

                _asyncLoadOperation = Application.LoadLevelAsync(_sceneName);
                yield return(_asyncLoadOperation);

                _asyncLoadOperation = null;
            }
            else
            {
                //start loading the new scene - note that even though this is a blocking call,
                //it actually starts a background thing, and from this moment on everything
                //is in Limbo
                Application.LoadLevel(_sceneName);
                _progress = 1;

                CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("Loading new scene {0} synchronously...", _sceneName));

                yield return(new WaitForEndOfFrame());

                yield return(new WaitForEndOfFrame());

                SceneLoadStarted();
            }

            GameApplication.Instance.ApplicationEvents.LevelLoaded -= OnLevelLoaded;

            if (_sceneManager.PendingLoadTask == this)
            {
                CoreLogger.LogDebug(LoggerModules.SceneManager, string.Format("resetting pending load from {0} to null", _name));
                _sceneManager.PendingLoadTask = null;
            }
        }
Example #19
0
 public ITask <TResource> LoadResource <TResource>(string path) where TResource : Object
 {
     CoreLogger.LogDebug(_loggerModule, string.Format("resource {0} requested - adding a loader task from bundle", path));
     return(new LoadFromBundleTask <TResource>(this, path));
 }
Example #20
0
 public void should_call_logdebug()
 {
     _coreLogger.LogDebug(_message);
     _logger.Validate(LogLevel.Debug, _message);
 }