12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using DG.Tweening;
- using UnityEngine.Serialization;
- public enum AniType
- {
- move,
- rota
- }
- public class ModelAniTool : MonoBehaviour
- {
- public string moveModelName;
- [FormerlySerializedAs("oriPos")] public Vector3 oriV3;
- [FormerlySerializedAs("targetPos")] public Vector3 targetV3;
- public float speed=1.0f;
- private GameObject targetObj;
- public AniType aniType;
-
-
- public void FindObje()
- {
- targetObj = this.transform.Find(moveModelName+"(Clone)").gameObject;
- ActionInstance._Instance.ModelAni_On += Ani_On;
- ActionInstance._Instance.ModelAni_Off += Ani_Off;
- }
- public void Ani_On()
- {
- switch (aniType)
- {
- case AniType.move:
- targetObj.transform.localPosition = oriV3;
- targetObj.transform.DOLocalMove(targetV3, speed);
- break;
- case AniType.rota:
- targetObj.transform.localEulerAngles = oriV3;
- targetObj.transform.DOLocalRotate(targetV3, speed);
- break;
-
- }
-
- }
- public void Ani_Off()
- {
- switch (aniType)
- {
- case AniType.move:
- targetObj.transform.localPosition = targetV3;
- targetObj.transform.DOLocalMove(oriV3, speed);
- break;
- case AniType.rota:
- targetObj.transform.localEulerAngles = targetV3;
- targetObj.transform.DOLocalRotate(oriV3, speed);
- break;
- }
- }
- }
|