Esempio n. 1
0
 void OnGraphicsDeviceReset()
 {
     // we need this to occur on the next frame so the camera bounds are updated
     Core.Schedule(0f, this, t =>
     {
         var self = t.Context as FollowCamera;
         self.Follow(self._targetEntity, self._cameraStyle);
     });
 }
Esempio n. 2
0
        protected IEnumerator LoadNextScene()
        {
            // let the listener know the screen is obscured if we have one
            if (OnScreenObscured != null)
            {
                OnScreenObscured();
            }

            // if we arent loading a new scene we just set the flag as if we did so that the 2 phase transitions complete
            if (!_loadsNewScene)
            {
                _isNewSceneLoaded = true;
                yield break;
            }

            if (LoadSceneOnBackgroundThread)
            {
                // load the Scene on a background thread
                Task.Run(() =>
                {
                    var scene = sceneLoadAction();

                    // get back to the main thread before setting the new Scene active. This isnt fantastic seeing as how
                    // the scheduler is not thread-safe but it should be empty between Scenes and SynchronizationContext.Current
                    // is null for some reason
                    Core.Schedule(0, false, null, timer =>
                    {
                        Core.Scene        = scene;
                        _isNewSceneLoaded = true;
                    });
                });
            }
            else
            {
                Core.Scene        = sceneLoadAction();
                _isNewSceneLoaded = true;
            }

            // wait for the scene to load if it was loaded on a background thread
            while (!_isNewSceneLoaded)
            {
                yield return(null);
            }
        }