private IObservable <Unit> PreLoadScene(Scenes[] targetScenes) { if (targetScenes.IsEmpty()) { return(Observable.ReturnUnit()); } var builder = new StringBuilder(); var observers = new List <IObservable <Unit> >(); foreach (var scene in targetScenes) { // キャッシュ済みのシーンがある場合はプリロードしない. if (cacheScenes.Any(x => x.Identifier == scene)) { continue; } var observer = Observable.Defer(() => Observable.FromMicroCoroutine(() => PreLoadCore(scene, builder))); observers.Add(observer); } if (observers.IsEmpty()) { return(Observable.ReturnUnit()); } var sw = System.Diagnostics.Stopwatch.StartNew(); return(observers.WhenAll() .Do(_ => { sw.Stop(); var time = sw.Elapsed.TotalMilliseconds; var detail = builder.ToString(); var message = string.Format("PreLoad Complete ({0:F2}ms)\n\n{1}", time, detail); UnityConsole.Event(ConsoleEventName, ConsoleEventColor, message); }) .AsUnitObservable()); }