예제 #1
0
 /// <summary>
 /// 生命周期跟随一个对象
 /// </summary>
 /// <param name="target"></param>
 /// <param name="ignoreTargetActive">忽略对象激活状态变化</param>
 public TimerTask DoFollow(MonoBehaviour target, FollowTargetMode followMode)
 {
     if (target == null)
     {
         return(this);
     }
     this.target           = target;
     followTargetType      = eFollowTargetType.Target1;
     this.followTargetMode = followMode;
     return(this);
 }
예제 #2
0
        /// <summary>
        /// 将当前Timers重置到刚创建出来的状态
        /// </summary>
        public virtual void Clear()
        {
            _fun    = null;
            _runner = null;
            Running = false;
            Stop    = false;
            Paused  = false;

            followTargetType = eFollowTargetType.None;

            target  = null;
            target2 = null;

            followTargetMode = FollowTargetMode.TargetDisactiveDoStop;

            _delayTime = 0;

            _loopDuration = 0;

            _loopCount = 0;

            IgnoreTimeScale = false;

            _savedDelayTime = 0;

            _savedLoopCount = 0;

            _savedLoopDuration = 0;


#if DEBUG_PERFORMANCE_TRACE
            stackInfo = null;
#endif
            if (addedUpdateListener)
            {
                TimerTaskManager.Instance.RemoveUpdateTimer(this);
            }

            addedUpdateListener = false;

            SavedParam1 = null;
            SavedParam2 = null;
            SavedParam3 = null;
            SavedParam4 = null;
        }
예제 #3
0
        public static TimerTask TimerStart(float delay, TimerTaskRunner runner, MonoBehaviour followtarget, MonoBehaviour followtarget2, FollowTargetMode followMode = FollowTargetMode.TargetDisactiveDoStop, bool ignoreTimeScale = true, int loopCount = 1, float loopduration = 0f
#if DEBUG_PERFORMANCE_TRACE
                                           , [CallerMemberName] string memberName    = null
                                           , [CallerFilePath] string path            = null
                                           , [CallerLineNumber] int sourceLineNumber = default(int)
#endif
                                           )
        {
            var task = Pool.GetATimer();

            task.Init(delay, runner, loopCount, loopduration
#if DEBUG_PERFORMANCE_TRACE
                      , memberName
                      , path
                      , sourceLineNumber
#endif
                      );
            task.IgnoreTimeScale = ignoreTimeScale;
            return(task.DoStart().DoFollow(followtarget, followMode));
            //return new TimerTask(delay, runner, loopCount, loopduration).DoFollow(followtarget, followMode).DoStart();
        }