// <summary> // 読み込み処理 </summary> public override IEnumerator Read() { do { using (WWW www = WWW.LoadFromCacheOrDownload(url + strExtensionAssetBundle, version)) { while (!www.isDone) { progress = www.progress; ++wwwCount; yield return(null); } string errorMessage = string.Empty; if (www.error != null) { errorMessage += www.error; } if (www.assetBundle == null) { errorMessage += "/null AssetBundle"; } if (errorMessage != string.Empty) { Debug.Log(errorMessage + "(AssetName:" + url + ")"); } else { { // オブジェクトを非同期ロード AssetBundleRequest request = www.assetBundle.LoadAsync(folder + "/" + strFileListName, typeof(TextAsset)); while (!request.isDone) { ++loadASyncCount; yield return(null); } Thread thread = new Thread(new ParameterizedThreadStart(UnpackFileList)); thread.Priority = System.Threading.ThreadPriority.Lowest; thread.Start((request.asset as TextAsset).bytes); while (thread.IsAlive) { ++msgpackCount; yield return(null); } } loadASyncCount = 0; for (int i = 0; i < fileList.obj.Count; ++i) { if (fileList.obj [i].Key == folder + "/" + strFileListName) { continue; // FileList skip. } AssetBundleRequest request = www.assetBundle.LoadAsync(fileList.obj [i].Key, WrapClass.GetType(fileList.obj [i].Value)); while (!request.isDone) { ++loadASyncCount; yield return(null); } objectList.Add(request.asset); } // threadの解放コードのお手本にはJoinが書かれているが mainthreadが止まるし目的が違うのでいらないはず www.assetBundle.Unload(false); readFlag = true; } yield return(null); } } while(readFlag == false); }
/// <summary> /// シーケンス実体 </summary> private IEnumerator Coroutine() { for (;;) { Debug.Log(currentSequence.data.sceneList[currentSequence.sceneIndex] + " index:" + currentSequence.sceneIndex); { SerializeData.Scene data = Resource.Instance.sceneList.Find(delegate(SerializeData.Scene s) { return(s.name == currentSequence.data.sceneList[currentSequence.sceneIndex]); }); currentScene = (Scene.Base)Activator.CreateInstance(WrapClass.GetType(data.functionName)); currentScene.Initialize(data); } currentScene.RequestLoad(ref GetComponent <FileAssetBundle> ().blockList); do { yield return(null); } while (GetComponent <FileAssetBundle> ().blockList.Find(delegate(Asset.Block block) { return(block.IsRead() == false); }) != null); currentScene.RequestStart(); do { if (currentScene.IsDone()) { break; } yield return(null); } while (true); currentScene.RequestUnload(); do { if (currentScene.IsUnload()) { break; } yield return(null); } while (true); switch (currentScene.endStatus) { case Scene.EndStatus.NEXT: if (currentSequence.sceneIndex < currentSequence.data.sceneList.Count - 1) { ++currentSequence.sceneIndex; } else { if (currentSequence.data.isLoop) { currentSequence.sceneIndex = 0; } else { if (currentSequence.data.next != string.Empty) { SerializeData.Sequence tmp = Resource.Instance.sequenceList.Find(delegate(SerializeData.Sequence seq) { return(seq.name == currentSequence.data.next); }); if (tmp != null) { currentSequence = new SequenceInfo(tmp); myStack.Push(currentSequence); } else { Debug.Log("no sequence"); } } else { if (myStack.Count > 1) { currentSequence = myStack.Pop(); } else { Debug.Log("root stack no back sequence"); } } } } break; case Scene.EndStatus.BACK: if (currentSequence.sceneIndex != 0) { --currentSequence.sceneIndex; } else { if (myStack.Count > 1) { currentSequence = myStack.Pop(); } else { Debug.Log("root stack no back sequence"); } } break; case Scene.EndStatus.ABORT: break; } Resources.UnloadUnusedAssets(); GC.Collect(); } }