Exemplo n.º 1
0
        internal async UniTask <ASceneGroup> LoadAsync(AReporter reporter)
        {
            reporter.SetCurrentSceneGroup(this);
            await reporter.InternalPrepareAsync();

            if (Ordering == E_SCENE_LOAD_ORDERING.RANDOM)
            {
                this.Scenes = SceneTypes.Select(x => (AScene)Activator.CreateInstance(x)).ToArray();
                var sceneLoadTasks = Scenes.Select(x => x.LoadAsync(reporter));
                await UniTask.WhenAll(sceneLoadTasks)
                .ContinueWith(async() => await PreLoadAsync(Scenes, reporter))
                .ContinueWith(async() => await reporter.ReportEnd());
            }
            else
            {
                this.Scenes = SceneTypes.Select(x => (AScene)Activator.CreateInstance(x)).ToArray();
                foreach (var scene in Scenes)
                {
                    await scene.LoadAsync(reporter);
                }
                await PreLoadAsync(Scenes, reporter);

                await reporter.ReportEnd();
            }
            reporter.SetCurrentSceneGroup(null);
            await AfterLoadAsync(Scenes);

            return(this);
        }