Beispiel #1
0
        //------------------------------------------------------------------------------------------------------------------------
        //														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");
            }
        }
Beispiel #2
0
        //  =============================================================================================================================
        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);
        }
Beispiel #3
0
        //  =============================================================================================================================

        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;
                    }
                }
            }
        }
Beispiel #4
0
 public void ClearTicks()
 {
     _ticks     -= _ticks;
     _lateTicks -= _lateTicks;
 }
Beispiel #5
0
 public void AddLateTick(ILateTick lateTick)
 {
     _lateTicks += lateTick.LateUpdate;
 }
Beispiel #6
0
 public void RemoveLateTick(ILateTick lateTick)
 {
     _lateTicks -= lateTick.LateUpdate;
 }
Beispiel #7
0
 private void ClearTicks()
 {
     _ticks     -= _ticks;
     _lateTicks -= _lateTicks;
 }