69 lines
2.3 KiB
C#
69 lines
2.3 KiB
C#
namespace Gameplay.Character
|
|
{
|
|
using Framework;
|
|
using UnityEngine;
|
|
|
|
public class CmpCharacterEffectPoints: MonoBehaviour
|
|
{
|
|
|
|
public Transform[] m_CriticalPoints;
|
|
public Transform[] m_OtherPoints;
|
|
|
|
#if UNITY_EDITOR
|
|
[Sirenix.OdinInspector.Button("自动设置")]
|
|
public void _AutoSet()
|
|
{
|
|
const string samplePath = "Assets/Art/Character/Prefabs/Players/P_A00000.prefab";
|
|
var sample = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(samplePath);
|
|
if (sample == null)
|
|
{
|
|
Debug.LogError($"找不到路径{samplePath}");
|
|
return;
|
|
}
|
|
|
|
var sampleCmp = sample.GetComponentInChildren<CmpCharacterEffectPoints>();
|
|
if (sampleCmp == null)
|
|
{
|
|
Debug.LogError($"找不到路径{samplePath}的CmpCharacterEffectPoints");
|
|
return;
|
|
}
|
|
|
|
var sampleCriticalPoints = sampleCmp.m_CriticalPoints;
|
|
var sampleOtherPoints = sampleCmp.m_OtherPoints;
|
|
// 通过名字重新在当前节点下进行寻找
|
|
m_CriticalPoints = new Transform[sampleCriticalPoints.Length];
|
|
m_OtherPoints = new Transform[sampleOtherPoints.Length];
|
|
var collector = new ComponentCollector(this.gameObject);
|
|
var skeleon = new Skeleton(collector.Transforms, this.gameObject.transform);
|
|
for (var i = 0; i < sampleCriticalPoints.Length; ++i)
|
|
{
|
|
var samplePoint = sampleCriticalPoints[i];
|
|
var point = skeleon.GetBone(samplePoint.name);
|
|
if (point == null)
|
|
{
|
|
Debug.LogError($"找不到节点{samplePoint.name}");
|
|
continue;
|
|
}
|
|
|
|
m_CriticalPoints[i] = point;
|
|
}
|
|
for (var i = 0; i < sampleOtherPoints.Length; ++i)
|
|
{
|
|
var samplePoin = sampleOtherPoints[i];
|
|
var point = skeleon.GetBone(samplePoin.name);
|
|
if (point == null)
|
|
{
|
|
DebugUtil.LogError($"找不到节点{samplePoin.name}");
|
|
continue;
|
|
}
|
|
|
|
m_OtherPoints[i] = point;
|
|
}
|
|
|
|
DebugUtil.Log("设置完成,请手动保存");
|
|
}
|
|
#endif
|
|
|
|
}
|
|
}
|