Beispiel #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);
     });
 }
Beispiel #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);
            }
        }