-
Notifications
You must be signed in to change notification settings - Fork 0
/
BoneNameExtractor.cs
79 lines (68 loc) · 2.28 KB
/
BoneNameExtractor.cs
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace BoneNameExtractor
{
public class BoneNameExtractor : MonoBehaviour { }
#if UNITY_EDITOR
[CustomEditor(typeof(BoneNameExtractor))]
public class BoneNameExtractorUI : Editor
{
public Animator HumanoidAnimator;
string logs;
public override void OnInspectorGUI()
{
//元のInspector部分を表示
base.OnInspectorGUI();
//ボタンを表示
if (GUILayout.Button("実行"))
{
BoneNameExtractor bnExtracotr = target as BoneNameExtractor;
HumanoidAnimator = bnExtracotr.GetComponent<Animator>();
if (HumanoidAnimator == null)
{
Debug.Log("AnimatorIsNull");
return;
}
if (HumanoidAnimator.isHuman == false)
{
Debug.Log("AvatarIsNotHuman");
return;
}
BoneNameExtract();
}
}
private void BoneNameExtract()
{
logs = $"<NAME>{HumanoidAnimator.name}</NAME>\n";
foreach (HumanBodyBones bone in Enum.GetValues(typeof(HumanBodyBones)))
{
Transform boneTf;
try
{
boneTf = HumanoidAnimator.GetBoneTransform(bone);
}catch(IndexOutOfRangeException e)
{
boneTf = null;
}
String boneID = bone.ToString();
String boneName = boneTf != null ? boneTf.name : "NONE";
logs = logs + $"<{boneID}>{boneName}</{boneID}>\n";
}
logs = logs +
"------Options------\n" +
"<RightBreastRoot>NONE</RightBreastRoot>\n" +
"<RightBreastMid>NONE</RightBreastMid>\n" +
"<RightBreastEnd>NONE</RightBreastEnd>\n" +
"<LeftBreastRoot>NONE</LeftBreastRoot>\n" +
"<LeftBreastMid>NONE</LeftBreastMid>\n" +
"<LeftBreastEnd>NONE</LeftBreastEnd>\n";
Debug.Log(logs);
}
}
#endif
}