void Update() { _log.Update(); if (_loader.ready) // 見ないでUpdate,Dumpを呼べば、初期化が終わるまでブロックするが動く。ブロックを嫌うならこれを見ておくこと。 { _loader.Update(); _sb.Length = 0; bool summaryOnly = (_fileList.Count > 20); _loader.Dump(_sb, summaryOnly); dump.text = _sb.ToString(); } // 破棄中は何もしない int sinceRelease = Time.frameCount - _releasedFrame; if (sinceRelease == (_releaseWait / 2)) { System.GC.Collect(); // GC走らせて素材消す } else if (sinceRelease == _releaseWait) { if (autoTestToggle.isOn) // 自動なら一定確率でキャッシュ消す { if (UnityEngine.Random.Range(0f, 1f) < 0.5f) { ClearStorageCache(); } } } if (sinceRelease < _releaseWait) { return; } if (autoTestToggle.isOn) { Load(); if (UnityEngine.Random.Range(0f, 1f) < 0.1f) { Release(); } if (UnityEngine.Random.Range(0f, 1f) < 0.1f) { if (!_listFileExists) { UpdateHashMap(); } } } }
void Update(int i) { #if USE_HANDLE_HOLDER if ((_handleHolder == null) || (_handleHolder.GetComponent <Kayac.LoadHandleHolder>().handleCount < HandleCount)) #else if (_handles[i] == null) #endif { var path = MakeRandomAssetName(); _texts[i].text = path + " loading..."; #if USE_CALLBACK #if USE_HANDLE_HOLDER if (_handleHolder == null) { _handleHolder = new GameObject("HandleHolder"); _handleHolder.transform.SetParent(gameObject.transform, false); } _loader.Load(path, asset => { if (asset != null) { OnLoadComplete(asset, i); } }, _handleHolder); #else _handles[i] = _loader.Load(path, asset => { if (asset != null) { OnLoadComplete(asset, i); } }); #endif #elif USE_COROUTINE StartCoroutine(CoLoad(i, path)); #else _handles[i] = _loader.Load(path); #endif } #if !USE_CALLBACK && !USE_COROUTINE if ((_handles[i] != null) && _handles[i].succeeded) { OnLoadComplete(_handles[i], i); } #endif _dump.text = _loader.Dump(); }