//------------------------------------------------------------------------------------------------------------------------ // Add() //------------------------------------------------------------------------------------------------------------------------ public void Add(GameObject gameObject) { MethodInfo info = gameObject.GetType().GetMethod("Update", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); if (info != null) { UpdateDelegate onUpdate = (UpdateDelegate)Delegate.CreateDelegate(typeof(UpdateDelegate), gameObject, info, false); if (onUpdate != null && !_updateReferences.ContainsKey(gameObject)) { _updateReferences[gameObject] = onUpdate; _updateDelegates += onUpdate; } } else { validateCase(gameObject, "Update"); } info = gameObject.GetType().GetMethod("LateUpdate", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); if (info != null) { LateUpdateDelegate onLateUpdate = (LateUpdateDelegate)Delegate.CreateDelegate(typeof(LateUpdateDelegate), gameObject, info, false); if (onLateUpdate != null && !_lateUpdateReferences.ContainsKey(gameObject)) { _lateUpdateReferences[gameObject] = onLateUpdate; _lateUpdateDelegates += onLateUpdate; } } else { validateCase(gameObject, "LateUpdate"); } }
// ============================================================================================================================= public bool joinLateUpdateCallBack(LateUpdateDelegate fun) { if (lateUpdateDelegate != null) { System.Delegate[] dArr = lateUpdateDelegate.GetInvocationList(); foreach (var item in dArr) { if (!item.Equals(fun)) { lateUpdateDelegate += fun; return(true); } else { break; } } } else { lateUpdateDelegate += fun; return(true); } return(false); }
// ============================================================================================================================= public void removeLateUpdateCallBack(LateUpdateDelegate fun) { if (lateUpdateDelegate == null) { return; } System.Delegate[] dArr = lateUpdateDelegate.GetInvocationList(); if (null != dArr) { foreach (var item in dArr) { if (item.Equals(fun)) { lateUpdateDelegate -= fun; break; } } } }
public void ClearTicks() { _ticks -= _ticks; _lateTicks -= _lateTicks; }
public void AddLateTick(ILateTick lateTick) { _lateTicks += lateTick.LateUpdate; }
public void RemoveLateTick(ILateTick lateTick) { _lateTicks -= lateTick.LateUpdate; }
private void ClearTicks() { _ticks -= _ticks; _lateTicks -= _lateTicks; }