public AsyncObject() { AsyncUpdateManager asyncUpdate = GameObject.FindObjectOfType <AsyncUpdateManager>(); asyncUpdate.AddTask( () => { if (OnPreUpdate != null) { OnPreUpdate(); } }, (state, isAsync) => { if (OnAsyncUpdate != null) { OnAsyncUpdate(state, isAsync); } }, () => { if (OnPostUpdate != null) { OnPostUpdate(); } }, () => useAsync, () => isActive ); }
public void Initialize() { AsyncUpdateManager asyncUpdate = GameObject.FindObjectOfType <AsyncUpdateManager>(); // shuffle count = (int)(UnityEngine.Random.value * 100 * (maxLevel + 1)); asyncUpdate.AddTask( () => { count++; if (count % split == 0) { if (OnPreUpdate != null) { OnPreUpdate(Time.deltaTime * split); } } }, (state, isAsync) => { if (count % split == 0) { if (OnAsyncUpdate != null) { OnAsyncUpdate(state.deltaTime * split); } } }, () => { if (count % split == 0) { if (OnPostUpdate != null) { OnPostUpdate(Time.deltaTime * split); } } }, () => useAsync, () => isActive ); OnLevelChanged += (level) => this.level = level; OnLevelChanged += (level) => useAsync = (level >= levelAsync); }