summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Test 1/TestErika.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-08-02 08:35:26 +0800
committerchai <chaifix@163.com>2021-08-02 08:35:26 +0800
commitce73a13f28e5a947df8f1f87f1f1be20010952ec (patch)
tree2c430bcd93f2c09bd35340def7c556c7294d6b5d /Assets/Scripts/Test 1/TestErika.cs
parent81acfeb9a1d88075899d9c21064330915caa59a4 (diff)
* 测试
Diffstat (limited to 'Assets/Scripts/Test 1/TestErika.cs')
-rw-r--r--Assets/Scripts/Test 1/TestErika.cs60
1 files changed, 60 insertions, 0 deletions
diff --git a/Assets/Scripts/Test 1/TestErika.cs b/Assets/Scripts/Test 1/TestErika.cs
new file mode 100644
index 00000000..c76f09e0
--- /dev/null
+++ b/Assets/Scripts/Test 1/TestErika.cs
@@ -0,0 +1,60 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class TestErika : MonoBehaviour
+{
+ public UnitActionData actionData; // 动作配置
+
+ public GameObject unitControllerPrefab;
+
+ public GameObject unitPrefab;
+
+ public RuntimeAnimatorController animController;
+
+ public string unitFolder;
+
+ [HideInInspector]
+ public GameObject unit;
+
+ [HideInInspector]
+ public GameObject unitController;
+
+ private void Awake()
+ {
+ unitController = GameObject.Instantiate(unitControllerPrefab);
+ unitController.transform.position = Vector3.zero;
+ unitController.transform.rotation = Quaternion.identity;
+ unit = GameObject.Instantiate(unitPrefab);
+ unit.transform.SetParent(unitController.transform);
+
+ Init();
+
+ }
+
+ private void Init()
+ {
+ UnitController unitCtr = unitController.GetOrAddComponent<UnitController>();
+ unitCtr.Initialize(unit);
+
+ UnitRootMotion unitRootMotion = unitCtr.unitRootMotion;
+
+ RootMotionProxy rootMotionProxy = unit.GetOrAddComponent<RootMotionProxy>();
+
+ Animator animator = unit.GetComponent<Animator>();
+ AnimatorOverrideController animCtr = new AnimatorOverrideController(animController);
+ animCtr.name = unitPrefab.name + " Override Controller";
+ animator.runtimeAnimatorController = animCtr;
+
+ foreach(var action in actionData.actions)
+ {
+ animCtr[action.Key.ToString()] = action.Value;
+ }
+
+ unitCtr.unitState.ChangeState(UnitState.EUnitState.Idle, new UnitState.IdleParam());
+
+ //unitCtr.unitRootMotion.SetUpRootMotion(unitFolder, actionData);
+
+ }
+
+}