From a6373aad477cd4d1e2d3115edb2a4169572dbc01 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 10 Oct 2018 13:15:08 +0900 Subject: [PATCH] Added ImorterContext.LoadCoroutine --- Core/Scripts/IO/ImporterContext.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Core/Scripts/IO/ImporterContext.cs b/Core/Scripts/IO/ImporterContext.cs index 5a709dc..e62f7eb 100644 --- a/Core/Scripts/IO/ImporterContext.cs +++ b/Core/Scripts/IO/ImporterContext.cs @@ -398,6 +398,28 @@ public void Load() schedulable.ExecuteAll(); } + public IEnumerator LoadCoroutine(Action onLoaded, Action onError = null) + { + if (onError == null) + { + onError = Debug.LogError; + } + + var schedulable = LoadAsync(); + foreach (var x in schedulable.GetRoot().Traverse()) + { + while (true) + { + var status = x.Execute(); + if (status != ExecutionStatus.Continue) + { + break; + } + yield return null; + } + } + } + public void LoadAsync(Action onLoaded, Action onError = null) { if (onError == null)