12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using ChivaXR;
- using Sirenix.OdinInspector;
- using System;
- using System.Collections;
- using System.Linq.Expressions;
- #if UNITY_EDITOR
- using UnityEditor;
- #endif
- using UnityEngine;
- public class AniDriver_ToolAnimationItem : AnimationDriverBase
- {
- [HorizontalGroup("AniGroup")]
- public ToolAnimationItem mToolAnimationItem;
- #if UNITY_EDITOR
- [HorizontalGroup("AniGroup")]
- [Button("选中ToolAnimationItem")]
- public void SelectMovePathItem()
- {
- if (mToolAnimationItem != null)
- {
- Selection.activeObject = mToolAnimationItem.gameObject;
- }
- }
- #endif
- #if UNITY_EDITOR
- [Header("反向播放")]
- #endif
- public bool reverse = false;
- public override void FinishedState()
- {
- mToolAnimationItem.SetFinishedState(reverse);
- }
- public override void InitState()
- {
- mToolAnimationItem.SetInitState(reverse);
- }
- public override void StartPlay(Action finishedCallBack = null)
- {
- StartAniCoroutine(PlayToolAnimation(mToolAnimationItem, reverse, finishedCallBack));
- }
- IEnumerator PlayToolAnimation(ToolAnimationItem toolAnimationItem, bool isReverse, Action finishedCallBack = null)
- {
- toolAnimationItem.Play();
- int i = 0;
- while (toolAnimationItem.PlayToolAnimation(isReverse))
- {
- i++;
- yield return new WaitForEndOfFrame();
- Debug.Log("PlayToolAnimation" + i);
- }
- finishedCallBack?.Invoke();
- }
- }
|