void LoopOnce()
 {
     position = Mathf.Clamp01(time);
     if (position >= 1)
     {
         enabled = false;
         if (OnStopCommand != null)
         {
             OnStopCommand.Send();
         }
         direction *= -1;
     }
 }
Exemple #2
0
 void LoopOnce()
 {
     print("call LoopOnce....");
     position = Mathf.Clamp01(time);
     if (position >= 1)
     {
         enabled = false;//脚本会被禁用 不会再调用FixedUpdate函数了
         if (OnStopCommand != null)
         {
             OnStopCommand.Send();
         }
         direction *= -1;// 方向反向
     }
     // 这里其实还可以加上一段
     // 当position <= 0 的时候, 方向再反转
 }