123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using ChivaXR;
- using System;
- using Sirenix.OdinInspector;
- /// <summary>
- /// 动画驱动器--- UnityAnimation
- /// </summary>
- public class AniDriver_UnityAnimation : AnimationDriverBase
- {
- public Animation animation;
- [ValueDropdown("GetAllAnimationNames")]
- public string aniName;
- public float speed = 1;
- public override void FinishedState()
- {
- AnimationToolkit.SetAnimationNormalizedToPose(animation, aniName, 1);
- }
- public override void InitState()
- {
- AnimationToolkit.SetAnimationNormalizedToPose(animation, aniName, 0);
- }
- public override void StartPlay(Action finishedCallBack = null)
- {
- AnimationToolkit.SetAnimationNormalizedToPlay(animation, aniName, 0, speed, finishedCallBack);
- }
- private IEnumerable GetAllAnimationNames()
- {
- List<ValueDropdownItem> item = new List<ValueDropdownItem>();
- if (animation != null)
- {
- foreach (AnimationState state in animation)
- {
- item.Add(new ValueDropdownItem(state.name, state.name));
- }
- }
- return item;
- }
- }
|