using UnityEngine; using UnityEditor; using UnityEngine.UIElements; using UnityEditor.UIElements; using System.Collections.Generic; /// /// 아바타의 휴먼본 이름을 Unity Human Bone 기준으로 변환하는 에디터 툴 /// 3ds Max Biped이나 다른 본 구조를 Unity 표준 이름으로 변환 /// public class HumanBoneRenamer : EditorWindow { private const string CommonUssPath = "Assets/Scripts/Streamingle/StreamingleControl/Editor/UXML/StreamingleCommon.uss"; private ObjectField avatarField; private ObjectField gameObjectField; // Unity Human Bone 매핑 테이블 private static readonly Dictionary humanBoneNames = new Dictionary() { // Body { HumanBodyBones.Hips, "Hips" }, { HumanBodyBones.Spine, "Spine" }, { HumanBodyBones.Chest, "Chest" }, { HumanBodyBones.UpperChest, "UpperChest" }, { HumanBodyBones.Neck, "Neck" }, { HumanBodyBones.Head, "Head" }, // Left Arm { HumanBodyBones.LeftShoulder, "LeftShoulder" }, { HumanBodyBones.LeftUpperArm, "LeftUpperArm" }, { HumanBodyBones.LeftLowerArm, "LeftLowerArm" }, { HumanBodyBones.LeftHand, "LeftHand" }, // Right Arm { HumanBodyBones.RightShoulder, "RightShoulder" }, { HumanBodyBones.RightUpperArm, "RightUpperArm" }, { HumanBodyBones.RightLowerArm, "RightLowerArm" }, { HumanBodyBones.RightHand, "RightHand" }, // Left Leg { HumanBodyBones.LeftUpperLeg, "LeftUpperLeg" }, { HumanBodyBones.LeftLowerLeg, "LeftLowerLeg" }, { HumanBodyBones.LeftFoot, "LeftFoot" }, { HumanBodyBones.LeftToes, "LeftToes" }, // Right Leg { HumanBodyBones.RightUpperLeg, "RightUpperLeg" }, { HumanBodyBones.RightLowerLeg, "RightLowerLeg" }, { HumanBodyBones.RightFoot, "RightFoot" }, { HumanBodyBones.RightToes, "RightToes" }, // Left Hand Fingers { HumanBodyBones.LeftThumbProximal, "LeftThumbProximal" }, { HumanBodyBones.LeftThumbIntermediate, "LeftThumbIntermediate" }, { HumanBodyBones.LeftThumbDistal, "LeftThumbDistal" }, { HumanBodyBones.LeftIndexProximal, "LeftIndexProximal" }, { HumanBodyBones.LeftIndexIntermediate, "LeftIndexIntermediate" }, { HumanBodyBones.LeftIndexDistal, "LeftIndexDistal" }, { HumanBodyBones.LeftMiddleProximal, "LeftMiddleProximal" }, { HumanBodyBones.LeftMiddleIntermediate, "LeftMiddleIntermediate" }, { HumanBodyBones.LeftMiddleDistal, "LeftMiddleDistal" }, { HumanBodyBones.LeftRingProximal, "LeftRingProximal" }, { HumanBodyBones.LeftRingIntermediate, "LeftRingIntermediate" }, { HumanBodyBones.LeftRingDistal, "LeftRingDistal" }, { HumanBodyBones.LeftLittleProximal, "LeftLittleProximal" }, { HumanBodyBones.LeftLittleIntermediate, "LeftLittleIntermediate" }, { HumanBodyBones.LeftLittleDistal, "LeftLittleDistal" }, // Right Hand Fingers { HumanBodyBones.RightThumbProximal, "RightThumbProximal" }, { HumanBodyBones.RightThumbIntermediate, "RightThumbIntermediate" }, { HumanBodyBones.RightThumbDistal, "RightThumbDistal" }, { HumanBodyBones.RightIndexProximal, "RightIndexProximal" }, { HumanBodyBones.RightIndexIntermediate, "RightIndexIntermediate" }, { HumanBodyBones.RightIndexDistal, "RightIndexDistal" }, { HumanBodyBones.RightMiddleProximal, "RightMiddleProximal" }, { HumanBodyBones.RightMiddleIntermediate, "RightMiddleIntermediate" }, { HumanBodyBones.RightMiddleDistal, "RightMiddleDistal" }, { HumanBodyBones.RightRingProximal, "RightRingProximal" }, { HumanBodyBones.RightRingIntermediate, "RightRingIntermediate" }, { HumanBodyBones.RightRingDistal, "RightRingDistal" }, { HumanBodyBones.RightLittleProximal, "RightLittleProximal" }, { HumanBodyBones.RightLittleIntermediate, "RightLittleIntermediate" }, { HumanBodyBones.RightLittleDistal, "RightLittleDistal" } }; [MenuItem("Tools/Bone Tools/휴먼본 이름 변환기")] public static void ShowWindow() { GetWindow("휴먼본 이름 변환기"); } public void CreateGUI() { var root = rootVisualElement; root.AddToClassList("tool-root"); var commonUss = AssetDatabase.LoadAssetAtPath(CommonUssPath); if (commonUss != null) root.styleSheets.Add(commonUss); root.Add(new Label("휴먼본 이름 변환기") { name = "title" }); root.Q