예제 #1
0
        public static ScenePromise TransitionScene(
            string from,
            string to)
        {
            if (from == null)
            {
                throw new Exception("Scene to transition from cannot be null.");
            }

            if (to == null)
            {
                throw new ApplicationException("Scene to transition to cannot be null.");
            }

            var promise = new ScenePromise();

            LoadScene(to)
            .OnProgress(progress =>
                        promise.UpdateProgress(progress / 2))
            .Then(() =>
                  UnloadScene(from)
                  .OnProgress(progress =>
                              promise.UpdateProgress(0.5f + progress / 2))
                  .Then(() =>
                        promise.Resolve()));

            return(promise);
        }
예제 #2
0
        public static ScenePromise UnloadScene(string scene)
        {
            if (string.IsNullOrEmpty(scene))
            {
                throw new Exception("Scene to unload cannot be null.");
            }

            var promise = new ScenePromise();

            Async.Coroutine.Start(
                UnloadSceneAsync(
                    scene,
                    (progress) => promise.UpdateProgress(progress),
                    () => promise.Resolve()));

            return(promise);
        }