blob: deafc7c36a2c3e81fbef60788b2358c3970c3cb6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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, "Assets/Bundle/Unit/PC/Erika/");
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(), true);
//unitCtr.unitRootMotion.SetUpRootMotion(unitFolder, actionData);
}
}
|