PreBuiltResources.cs 7.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using TriLibCore.General;
  2. using TriLibCore.Mappers;
  3. using TriLibCore.Utils;
  4. using UnityEditor;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. using HumanLimit = TriLibCore.General.HumanLimit;
  8. namespace TriLibCore.Editor
  9. {
  10. public class PreBuiltResources : UnityEditor.Editor
  11. {
  12. [MenuItem("Assets/Create/TriLib/Asset Loader Options/Pre-built Asset Loader Options")]
  13. public static void CreatePreBuiltAssetLoaderOptions()
  14. {
  15. var assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions(false, true);
  16. AssetDatabase.CreateAsset(assetLoaderOptions, $"{FileUtils.GetFileDirectory(AssetDatabase.GetAssetPath(Selection.activeObject))}/AssetLoaderOptions.asset");
  17. }
  18. [MenuItem("Assets/Create/TriLib/Mappers/Humanoid/Mixamo and Biped By Name Humanoid Avatar Mapper")]
  19. public static void CreateMixamoAndBipedMapper()
  20. {
  21. var humanLimit = new HumanLimit();
  22. var mapper = CreateInstance<ByNameHumanoidAvatarMapper>();
  23. mapper.AddMapping(HumanBodyBones.Head, humanLimit, "Head", "Head1");
  24. mapper.AddMapping(HumanBodyBones.Neck, humanLimit, "Neck", "Neck1");
  25. mapper.AddMapping(HumanBodyBones.Chest, humanLimit, "Spine1");
  26. mapper.AddMapping(HumanBodyBones.UpperChest, humanLimit, "Spine4", "Spine3", "Spine2", "Spine1");
  27. mapper.AddMapping(HumanBodyBones.Spine, humanLimit, "Spine");
  28. mapper.AddMapping(HumanBodyBones.Hips, humanLimit, "Hips", "Bip01", "Pelvis");
  29. mapper.AddMapping(HumanBodyBones.LeftShoulder, humanLimit, "LeftShoulder", "L Clavicle", "L_Clavicle");
  30. mapper.AddMapping(HumanBodyBones.LeftUpperArm, humanLimit, "LeftArm", "L UpperArm", "L_UpperArm");
  31. mapper.AddMapping(HumanBodyBones.LeftLowerArm, humanLimit, "LeftForeArm", "L Forearm", "L_Forearm");
  32. mapper.AddMapping(HumanBodyBones.LeftHand, humanLimit, "LeftHand", "L Hand", "L_Hand", "LeftWrist");
  33. mapper.AddMapping(HumanBodyBones.RightShoulder, humanLimit, "RightShoulder", "R Clavicle", "R_Clavicle");
  34. mapper.AddMapping(HumanBodyBones.RightUpperArm, humanLimit, "RightArm", "R UpperArm", "R_UpperArm");
  35. mapper.AddMapping(HumanBodyBones.RightLowerArm, humanLimit, "RightForeArm", "R Forearm", "R_Forearm");
  36. mapper.AddMapping(HumanBodyBones.RightHand, humanLimit, "RightHand", "R Hand", "R_Hand", "RightWrist");
  37. mapper.AddMapping(HumanBodyBones.LeftUpperLeg, humanLimit, "LeftUpLeg", "L Thigh", "L_Thigh");
  38. mapper.AddMapping(HumanBodyBones.LeftLowerLeg, humanLimit, "LeftLeg", "L Calf", "L_Calf");
  39. mapper.AddMapping(HumanBodyBones.LeftFoot, humanLimit, "LeftFoot", "L Foot", "L_Foot");
  40. mapper.AddMapping(HumanBodyBones.LeftToes, humanLimit, "LeftToeBase", "L Toe0", "L_Toe0");
  41. mapper.AddMapping(HumanBodyBones.RightUpperLeg, humanLimit, "RightUpLeg", "R Thigh", "R_Thigh");
  42. mapper.AddMapping(HumanBodyBones.RightLowerLeg, humanLimit, "RightLeg", "R Calf", "R_Calf");
  43. mapper.AddMapping(HumanBodyBones.RightFoot, humanLimit, "RightFoot", "R Foot", "R_Foot");
  44. mapper.AddMapping(HumanBodyBones.RightToes, humanLimit, "RightToeBase", "R Toe0", "R_Toe0");
  45. mapper.AddMapping(HumanBodyBones.LeftThumbProximal, humanLimit, "LeftHandThumb1", "L Finger0", "L_Finger0");
  46. mapper.AddMapping(HumanBodyBones.LeftThumbIntermediate, humanLimit, "LeftHandThumb2", "L Finger01", "L_Finger01");
  47. mapper.AddMapping(HumanBodyBones.LeftThumbDistal, humanLimit, "LeftHandThumb3", "L Finger02", "L_Finger02");
  48. mapper.AddMapping(HumanBodyBones.LeftIndexProximal, humanLimit, "LeftHandIndex1", "L Finger1", "L_Finger1");
  49. mapper.AddMapping(HumanBodyBones.LeftIndexIntermediate, humanLimit, "LeftHandIndex2", "L Finger11", "L_Finger11");
  50. mapper.AddMapping(HumanBodyBones.LeftIndexDistal, humanLimit, "LeftHandIndex3", "L Finger12", "L_Finger12");
  51. mapper.AddMapping(HumanBodyBones.LeftMiddleProximal, humanLimit, "LeftHandMiddle1", "L Finger2", "L_Finger2");
  52. mapper.AddMapping(HumanBodyBones.LeftMiddleIntermediate, humanLimit, "LeftHandMiddle2", "L Finger21", "L_Finger21");
  53. mapper.AddMapping(HumanBodyBones.LeftMiddleDistal, humanLimit, "LeftHandMiddle3", "L Finger22", "L_Finger22");
  54. mapper.AddMapping(HumanBodyBones.LeftRingProximal, humanLimit, "LeftHandRing1", "L Finger3", "L_Finger3");
  55. mapper.AddMapping(HumanBodyBones.LeftRingIntermediate, humanLimit, "LeftHandRing2", "L Finger31", "L_Finger31");
  56. mapper.AddMapping(HumanBodyBones.LeftRingDistal, humanLimit, "LeftHandRing3", "L Finger32", "L_Finger32");
  57. mapper.AddMapping(HumanBodyBones.LeftLittleProximal, humanLimit, "LeftHandPinky1", "L Finger4", "L_Finger4");
  58. mapper.AddMapping(HumanBodyBones.LeftLittleIntermediate, humanLimit, "LeftHandPinky2", "L Finger41", "L_Finger41");
  59. mapper.AddMapping(HumanBodyBones.LeftLittleDistal, humanLimit, "LeftHandPinky3", "L Finger42", "L_Finger42");
  60. mapper.AddMapping(HumanBodyBones.RightThumbProximal, humanLimit, "RightHandThumb1", "R Finger0", "R_Finger0");
  61. mapper.AddMapping(HumanBodyBones.RightThumbIntermediate, humanLimit, "RightHandThumb2", "R Finger01", "R_Finger01");
  62. mapper.AddMapping(HumanBodyBones.RightThumbDistal, humanLimit, "RightHandThumb3", "R Finger02", "R_Finger02");
  63. mapper.AddMapping(HumanBodyBones.RightIndexProximal, humanLimit, "RightHandIndex1", "R Finger1", "R_Finger1");
  64. mapper.AddMapping(HumanBodyBones.RightIndexIntermediate, humanLimit, "RightHandIndex2", "R Finger11", "R_Finger11");
  65. mapper.AddMapping(HumanBodyBones.RightIndexDistal, humanLimit, "RightHandIndex3", "R Finger12", "R_Finger12");
  66. mapper.AddMapping(HumanBodyBones.RightMiddleProximal, humanLimit, "RightHandMiddle1", "R Finger2", "R_Finger2");
  67. mapper.AddMapping(HumanBodyBones.RightMiddleIntermediate, humanLimit, "RightHandMiddle2", "R Finger21", "R_Finger21");
  68. mapper.AddMapping(HumanBodyBones.RightMiddleDistal, humanLimit, "RightHandMiddle3", "R Finger22", "R_Finger22");
  69. mapper.AddMapping(HumanBodyBones.RightRingProximal, humanLimit, "RightHandRing1", "R Finger3", "R_Finger3");
  70. mapper.AddMapping(HumanBodyBones.RightRingIntermediate, humanLimit, "RightHandRing2", "R Finger31", "R_Finger31");
  71. mapper.AddMapping(HumanBodyBones.RightRingDistal, humanLimit, "RightHandRing3", "R Finger32", "R_Finger32");
  72. mapper.AddMapping(HumanBodyBones.RightLittleProximal, humanLimit, "RightHandPinky1", "R Finger4", "R_Finger4");
  73. mapper.AddMapping(HumanBodyBones.RightLittleIntermediate, humanLimit, "RightHandPinky2", "R Finger41", "R_Finger41");
  74. mapper.AddMapping(HumanBodyBones.RightLittleDistal, humanLimit, "RightHandPinky3", "R Finger42", "R_Finger42");
  75. mapper.CaseInsensitive = true;
  76. mapper.stringComparisonMode = StringComparisonMode.LeftEndsWithRight;
  77. AssetDatabase.CreateAsset(mapper, $"{FileUtils.GetFileDirectory(AssetDatabase.GetAssetPath(Selection.activeObject))}/MixamoAndBipedByNameHumanoidAvatarMapper.asset");
  78. }
  79. }
  80. }