diff --git a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/InternalTPose.cs b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/InternalTPose.cs index 703068203..7d6d1e294 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/InternalTPose.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/InternalTPose.cs @@ -149,7 +149,7 @@ namespace UniGLTF var existingMappings = new Dictionary(); var animator = go.GetComponent(); - foreach (HumanBodyBones bone in Enum.GetValues(typeof(HumanBodyBones))) + foreach (var bone in CachedEnum.GetValues()) { if (bone == HumanBodyBones.LastBone) { diff --git a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/M17N.cs b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/M17N.cs index 69e8c2fb7..3f2c00c4c 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/M17N.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/M17N.cs @@ -28,7 +28,7 @@ namespace UniGLTF.M17N } } - public static class MsgCache where T : Enum + public static class MsgCache where T : struct, Enum { static Dictionary> s_cache = new Dictionary>(); @@ -57,7 +57,7 @@ namespace UniGLTF.M17N map = new Dictionary(); var t = typeof(T); - foreach (T value in Enum.GetValues(t)) + foreach (T value in CachedEnum.GetValues()) { var match = GetAttribute(value, language); // Attribute。無かったら enum の ToString @@ -107,7 +107,7 @@ namespace UniGLTF.M17N } } - public static string Msg(this T key) where T : Enum + public static string Msg(this T key) where T : struct, Enum { return MsgCache.Get(Lang, key); } diff --git a/Assets/UniGLTF/Editor/UniGLTF/Gizmo/BoneInfo.cs b/Assets/UniGLTF/Editor/UniGLTF/Gizmo/BoneInfo.cs index 09cb3a798..c6d5f9817 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/Gizmo/BoneInfo.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/Gizmo/BoneInfo.cs @@ -129,7 +129,7 @@ namespace UniGLTF throw new ArgumentException("not humanoid"); } - var validBones = ((HumanBodyBones[])Enum.GetValues(typeof(HumanBodyBones))) + var validBones = CachedEnum.GetValues() .Where(x => x != HumanBodyBones.LastBone) .ToArray(); var headSelectedBones = new HashSet(); diff --git a/Assets/VRM/Editor/Format/VRMEditorExporter.cs b/Assets/VRM/Editor/Format/VRMEditorExporter.cs index 4c2755d82..a15205344 100644 --- a/Assets/VRM/Editor/Format/VRMEditorExporter.cs +++ b/Assets/VRM/Editor/Format/VRMEditorExporter.cs @@ -171,8 +171,7 @@ namespace VRM // copy先 var afterTransforms = target.GetComponentsInChildren(); // copy先のhumanoidBoneのリストを得る - var bones = (HumanBodyBones[])Enum.GetValues(typeof(HumanBodyBones)); - var humanTransforms = bones + var humanTransforms = CachedEnum.GetValues() .Where(x => x != HumanBodyBones.LastBone) .Select(x => animator.GetBoneTransform(x)) .Where(x => x != null) diff --git a/Assets/VRM/Runtime/IO/VRMExporter.cs b/Assets/VRM/Runtime/IO/VRMExporter.cs index 1b5c06422..72e463bae 100644 --- a/Assets/VRM/Runtime/IO/VRMExporter.cs +++ b/Assets/VRM/Runtime/IO/VRMExporter.cs @@ -72,7 +72,7 @@ namespace VRM { // set humanoid bone mapping var avatar = animator.avatar; - foreach (HumanBodyBones key in Enum.GetValues(typeof(HumanBodyBones))) + foreach (HumanBodyBones key in CachedEnum.GetValues()) { if (key == HumanBodyBones.LastBone) { diff --git a/Assets/VRM/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs b/Assets/VRM/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs index 8d9154692..24742bcbe 100644 --- a/Assets/VRM/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs +++ b/Assets/VRM/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using UniGLTF; using UniGLTF.MeshUtility; using UniHumanoid; using UnityEngine; @@ -71,8 +72,7 @@ namespace VRM { var src = _src.GetComponent(); - var srcHumanBones = Enum.GetValues(typeof(HumanBodyBones)) - .Cast() + var srcHumanBones = CachedEnum.GetValues() .Where(x => x != HumanBodyBones.LastBone) .Select(x => new { Key = x, Value = src.GetBoneTransform(x) }) .Where(x => x.Value != null) diff --git a/Assets/VRM10/Editor/Components/Expression/ReorderableMaterialColorBindingList.cs b/Assets/VRM10/Editor/Components/Expression/ReorderableMaterialColorBindingList.cs index 2a190975e..0baaf81bd 100644 --- a/Assets/VRM10/Editor/Components/Expression/ReorderableMaterialColorBindingList.cs +++ b/Assets/VRM10/Editor/Components/Expression/ReorderableMaterialColorBindingList.cs @@ -1,4 +1,5 @@ using System; +using UniGLTF; using UnityEditor; using UnityEditorInternal; using UnityEngine; @@ -52,7 +53,7 @@ namespace UniVRM10 // 対象のプロパティを enum から選択する var bindTypeProp = property.FindPropertyRelative("BindType"); - var bindTypes = (UniGLTF.Extensions.VRMC_vrm.MaterialColorType[])Enum.GetValues(typeof(UniGLTF.Extensions.VRMC_vrm.MaterialColorType)); + var bindTypes = CachedEnum.GetValues(); var bindType = bindTypes[bindTypeProp.enumValueIndex]; var newBindType = ExpressionEditorHelper.EnumPopup(rect, bindType); if (newBindType != bindType) diff --git a/Assets/VRM10/Editor/Vrm10InstanceEditor.cs b/Assets/VRM10/Editor/Vrm10InstanceEditor.cs index e51dc38dc..35aa561d6 100644 --- a/Assets/VRM10/Editor/Vrm10InstanceEditor.cs +++ b/Assets/VRM10/Editor/Vrm10InstanceEditor.cs @@ -136,7 +136,7 @@ namespace UniVRM10 if (!string.IsNullOrEmpty(dir)) { var expressions = new Dictionary(); - foreach (ExpressionPreset expression in System.Enum.GetValues(typeof(ExpressionPreset))) + foreach (ExpressionPreset expression in CachedEnum.GetValues()) { if (expression == ExpressionPreset.custom) { diff --git a/Assets/VRM10/Runtime/IO/Model/ModelExporter.cs b/Assets/VRM10/Runtime/IO/Model/ModelExporter.cs index 899537002..a1ad13ecb 100644 --- a/Assets/VRM10/Runtime/IO/Model/ModelExporter.cs +++ b/Assets/VRM10/Runtime/IO/Model/ModelExporter.cs @@ -40,7 +40,7 @@ namespace UniVRM10 humanoid.AssignBonesFromAnimator(); } - foreach (HumanBodyBones humanBoneType in Enum.GetValues(typeof(HumanBodyBones))) + foreach (HumanBodyBones humanBoneType in CachedEnum.GetValues()) { var transform = humanoid.GetBoneTransform(humanBoneType); if (transform != null && Nodes.TryGetValue(transform.gameObject, out VrmLib.Node node)) diff --git a/Assets/VRM10/vrmlib/Runtime/Humanoid/Humanoid.cs b/Assets/VRM10/vrmlib/Runtime/Humanoid/Humanoid.cs index 8f21319be..5dc1c349d 100644 --- a/Assets/VRM10/vrmlib/Runtime/Humanoid/Humanoid.cs +++ b/Assets/VRM10/vrmlib/Runtime/Humanoid/Humanoid.cs @@ -2,6 +2,7 @@ using System; using System.Linq; using System.Collections; using System.Collections.Generic; +using UniGLTF; using UnityEngine; @@ -457,7 +458,7 @@ namespace VrmLib public void Clear() { - foreach (HumanoidBones key in Enum.GetValues(typeof(HumanoidBones))) + foreach (HumanoidBones key in CachedEnum.GetValues()) { Add(key, null); } diff --git a/Assets/VRM10/vrmlib/Runtime/Model.cs b/Assets/VRM10/vrmlib/Runtime/Model.cs index 0cb16a501..eca169da1 100644 --- a/Assets/VRM10/vrmlib/Runtime/Model.cs +++ b/Assets/VRM10/vrmlib/Runtime/Model.cs @@ -115,10 +115,10 @@ namespace VrmLib // HumanoidBonesでBoneRequiredAttributeが定義されているものすべてが使われているかどうかを判断 var boneattributes - = Enum.GetValues(typeof(HumanoidBones)).Cast() - .Select(bone => bone.GetType().GetField(bone.ToString())) - .Select(info => info.GetCustomAttributes(typeof(BoneRequiredAttribute), false) as BoneRequiredAttribute[]) - .Where(attributes => attributes.Length > 0); + = CachedEnum.GetValues() + .Select(bone => bone.GetType().GetField(bone.ToString())) + .Select(info => info.GetCustomAttributes(typeof(BoneRequiredAttribute), false) as BoneRequiredAttribute[]) + .Where(attributes => attributes.Length > 0); var nodeHumanoids = vrmhumanoids diff --git a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs index d29896e85..62ede917f 100644 --- a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs +++ b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs @@ -276,7 +276,7 @@ namespace UniVRM10.VRM10Viewer { var controlRig = m_controller.Runtime.ControlRig; - foreach (HumanBodyBones bone in Enum.GetValues(typeof(HumanBodyBones))) + foreach (HumanBodyBones bone in CachedEnum.GetValues()) { if (bone == HumanBodyBones.LastBone) {