public static void DestroyChild(this Transform @this, int index, bool immediate = false)
 {
     if (@this != null && @this.childCount > index)
     {
         GameObjectExtend.DestroyGameObject(@this.GetChild(index).gameObject, immediate);
     }
 }
Beispiel #2
0
        private void Update()
        {
            if (init && _timer != null && originTransform && (!useCurve || curve != null) && (!originUpdate || originTransform != null) && (!isTarget || targetTransform != null))
            {
                float percent = useCurve && curve != null?curve.Evaluate(_timer.TimeInPercent) : _timer.TimeInPercent;

                Vector3 pointA = originUpdate ? originTransform.position : _origin;
                Vector3 pointb = isTarget ? targetTransform.position : _destnation;

                Vector3 currentPosition = Vector3.Lerp(pointA, pointb, percent);

                if (agentTransform)
                {
                    agentTransform.position = currentPosition;
                }

                if (_timer.IsFinish())
                {
                    onFinish.Invoke(gameObject);
                    ResetTranslation();
                    if (destroyAtFinish)
                    {
                        GameObjectExtend.DestroyGameObject(gameObject);
                    }
                }
            }
        }
 public void Stop()
 {
     _play = false;
     _timer.ResetOff();
     if (destoryAtFinish)
     {
         GameObjectExtend.DestroyGameObject(gameObject);
     }
 }
 public void DestroyAudioSource()
 {
     GameObjectExtend.DestroyGameObject(gameObject);
 }
 private void OnFinishTime(TimerContainer container, float left, float right)
 {
     GameObjectExtend.DestroyGameObject(gameObject);
 }