diff --git a/Assets/VRM10/Runtime/ControlRig/InitialRotationPoseProvider.cs b/Assets/VRM10/Runtime/ControlRig/InitialRotationPoseProvider.cs index e87769866..486432692 100644 --- a/Assets/VRM10/Runtime/ControlRig/InitialRotationPoseProvider.cs +++ b/Assets/VRM10/Runtime/ControlRig/InitialRotationPoseProvider.cs @@ -25,11 +25,11 @@ namespace UniVRM10 public InitRotationPoseProvider(Transform root, UniHumanoid.Humanoid humanoid) { m_root = root; - m_hips = m_bones[HumanBodyBones.Hips].Transform; foreach (var (t, bone) in humanoid.BoneMap) { m_bones.Add(bone, new BoneInitialRotation(t)); } + m_hips = m_bones[HumanBodyBones.Hips].Transform; } Quaternion INormalizedPoseProvider.GetNormalizedLocalRotation(HumanBodyBones bone, HumanBodyBones parentBone) diff --git a/Assets/VRM10_Samples/VRM10Viewer/VRM10Motion.cs b/Assets/VRM10_Samples/VRM10Viewer/VRM10Motion.cs index b165fd69f..89ae35c64 100644 --- a/Assets/VRM10_Samples/VRM10Viewer/VRM10Motion.cs +++ b/Assets/VRM10_Samples/VRM10Viewer/VRM10Motion.cs @@ -68,5 +68,139 @@ namespace UniVRM10.VRM10Viewer } } } + + static int? GetNodeIndex(UniGLTF.Extensions.VRMC_vrm_animation.Humanoid humanoid, HumanBodyBones bone) + { + switch (bone) + { + case HumanBodyBones.Hips: return humanoid.Hips?.Node; + case HumanBodyBones.LeftUpperLeg: return humanoid.LeftUpperLeg?.Node; + case HumanBodyBones.RightUpperLeg: return humanoid.RightUpperLeg?.Node; + case HumanBodyBones.LeftLowerLeg: return humanoid.LeftLowerLeg?.Node; + case HumanBodyBones.RightLowerLeg: return humanoid.RightLowerLeg?.Node; + case HumanBodyBones.LeftFoot: return humanoid.LeftFoot?.Node; + case HumanBodyBones.RightFoot: return humanoid.RightFoot?.Node; + case HumanBodyBones.Spine: return humanoid.Spine?.Node; + case HumanBodyBones.Chest: return humanoid.Chest?.Node; + case HumanBodyBones.Neck: return humanoid.Neck?.Node; + case HumanBodyBones.Head: return humanoid.Head?.Node; + case HumanBodyBones.LeftShoulder: return humanoid.LeftShoulder?.Node; + case HumanBodyBones.RightShoulder: return humanoid.RightShoulder?.Node; + case HumanBodyBones.LeftUpperArm: return humanoid.LeftUpperArm?.Node; + case HumanBodyBones.RightUpperArm: return humanoid.RightUpperArm?.Node; + case HumanBodyBones.LeftLowerArm: return humanoid.LeftLowerArm?.Node; + case HumanBodyBones.RightLowerArm: return humanoid.RightLowerArm?.Node; + case HumanBodyBones.LeftHand: return humanoid.LeftHand?.Node; + case HumanBodyBones.RightHand: return humanoid.RightHand?.Node; + case HumanBodyBones.LeftToes: return humanoid.LeftToes?.Node; + case HumanBodyBones.RightToes: return humanoid.RightToes?.Node; + // case HumanBodyBones.LeftEye: return humanoid.LeftEye?.Node; + // case HumanBodyBones.RightEye: return humanoid.RightEye?.Node; + case HumanBodyBones.Jaw: return humanoid.Jaw?.Node; + case HumanBodyBones.LeftThumbProximal: return humanoid.LeftThumbMetacarpal?.Node; // Metacarpal + case HumanBodyBones.LeftThumbIntermediate: return humanoid.LeftThumbProximal?.Node; // Proximal + case HumanBodyBones.LeftThumbDistal: return humanoid.LeftThumbDistal?.Node; + case HumanBodyBones.LeftIndexProximal: return humanoid.LeftIndexProximal?.Node; + case HumanBodyBones.LeftIndexIntermediate: return humanoid.LeftIndexIntermediate?.Node; + case HumanBodyBones.LeftIndexDistal: return humanoid.LeftIndexDistal?.Node; + case HumanBodyBones.LeftMiddleProximal: return humanoid.LeftMiddleProximal?.Node; + case HumanBodyBones.LeftMiddleIntermediate: return humanoid.LeftMiddleIntermediate?.Node; + case HumanBodyBones.LeftMiddleDistal: return humanoid.LeftMiddleDistal?.Node; + case HumanBodyBones.LeftRingProximal: return humanoid.LeftRingProximal?.Node; + case HumanBodyBones.LeftRingIntermediate: return humanoid.LeftRingIntermediate?.Node; + case HumanBodyBones.LeftRingDistal: return humanoid.LeftRingDistal?.Node; + case HumanBodyBones.LeftLittleProximal: return humanoid.LeftLittleProximal?.Node; + case HumanBodyBones.LeftLittleIntermediate: return humanoid.LeftLittleIntermediate?.Node; + case HumanBodyBones.LeftLittleDistal: return humanoid.LeftLittleDistal?.Node; + case HumanBodyBones.RightThumbProximal: return humanoid.RightThumbMetacarpal?.Node; // Metacarpal + case HumanBodyBones.RightThumbIntermediate: return humanoid.RightThumbProximal?.Node; // Proximal + case HumanBodyBones.RightThumbDistal: return humanoid.RightThumbDistal?.Node; + case HumanBodyBones.RightIndexProximal: return humanoid.RightIndexProximal?.Node; + case HumanBodyBones.RightIndexIntermediate: return humanoid.RightIndexIntermediate?.Node; + case HumanBodyBones.RightIndexDistal: return humanoid.RightIndexDistal?.Node; + case HumanBodyBones.RightMiddleProximal: return humanoid.RightMiddleProximal?.Node; + case HumanBodyBones.RightMiddleIntermediate: return humanoid.RightMiddleIntermediate?.Node; + case HumanBodyBones.RightMiddleDistal: return humanoid.RightMiddleDistal?.Node; + case HumanBodyBones.RightRingProximal: return humanoid.RightRingProximal?.Node; + case HumanBodyBones.RightRingIntermediate: return humanoid.RightRingIntermediate?.Node; + case HumanBodyBones.RightRingDistal: return humanoid.RightRingDistal?.Node; + case HumanBodyBones.RightLittleProximal: return humanoid.RightLittleProximal?.Node; + case HumanBodyBones.RightLittleIntermediate: return humanoid.RightLittleIntermediate?.Node; + case HumanBodyBones.RightLittleDistal: return humanoid.RightLittleDistal?.Node; + case HumanBodyBones.UpperChest: return humanoid.UpperChest?.Node; + } + return default; + } + + static Dictionary GetHumanMap(GltfData data, IReadOnlyList nodes) + { + var humanMap = new Dictionary(); + + + if (data.GLTF.extensions is UniGLTF.glTFExtensionImport extensions) + { + foreach (var kv in extensions.ObjectItems()) + { + if (kv.Key.GetString() == "VRMC_vrm_animation") + { + var animation = UniGLTF.Extensions.VRMC_vrm_animation.GltfDeserializer.Deserialize(kv.Value); + foreach (HumanBodyBones bone in UniGLTF.Utils.CachedEnum.GetValues()) + { + // Debug.Log($"{bone} => {index}"); + var node = GetNodeIndex(animation.Humanoid, bone); + if (node.HasValue) + { + humanMap.Add(bone, nodes[node.Value]); + } + } + } + } + } + return humanMap; + } + + public static async Task LoadVrmAnimationFromPathAsync(string path) + { + // + // GetHumanoid Mapping + // + using (GltfData data = new AutoGltfFileParser(path).Parse()) + using (var loader = new UniGLTF.ImporterContext(data)) + { + loader.InvertAxis = Axes.X; + // loader.PositionScaling = 0.01f; + var instance = await loader.LoadAsync(new ImmediateCaller()); + var humanMap = GetHumanMap(data, loader.Nodes); + if (humanMap.Count == 0) + { + throw new ArgumentException("fail to load VRMC_vrm_animation"); + } + + var description = AvatarDescription.Create(humanMap); + + // + // avatar + // + var avatar = description.CreateAvatar(instance.Root.transform); + avatar.name = "Avatar"; + // AvatarDescription = description; + var animator = instance.gameObject.AddComponent(); + animator.avatar = avatar; + + // create SkinnedMesh for bone visualize + var renderer = SkeletonMeshUtility.CreateRenderer(animator); + var material = new Material(Shader.Find("Standard")); + renderer.sharedMaterial = material; + var mesh = renderer.sharedMesh; + mesh.name = "box-man"; + + var humanoid = instance.gameObject.AddComponent(); + humanoid.AssignBonesFromAnimator(); + var motion = new VRM10Motion(instance); + var provider = new InitRotationPoseProvider(instance.transform, humanoid); + motion.ControlRig = (provider, provider); + return motion; + } + } } } diff --git a/Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity b/Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity index 15284a929..b6a73865f 100644 --- a/Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity +++ b/Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity @@ -230,7 +230,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 339774397} - m_RootOrder: 11 + m_RootOrder: 12 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -394,6 +394,127 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 154330167} m_CullTransparentMesh: 0 +--- !u!1 &168425994 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 168425995} + - component: {fileID: 168425998} + - component: {fileID: 168425997} + - component: {fileID: 168425996} + m_Layer: 5 + m_Name: OpenMotion + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &168425995 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 168425994} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1923525315} + m_Father: {fileID: 339774397} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 162, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &168425996 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 168425994} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Highlighted + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 168425997} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &168425997 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 168425994} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &168425998 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 168425994} + m_CullTransparentMesh: 0 --- !u!1 &175751362 GameObject: m_ObjectHideFlags: 0 @@ -642,7 +763,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 339774397} - m_RootOrder: 3 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -1097,6 +1218,7 @@ RectTransform: m_Children: - {fileID: 1621794411} - {fileID: 2009818432} + - {fileID: 168425995} - {fileID: 1557052150} - {fileID: 224350191} - {fileID: 1791103379} @@ -1595,7 +1717,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 339774397} - m_RootOrder: 7 + m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -1675,7 +1797,7 @@ RectTransform: - {fileID: 154330168} - {fileID: 1954133885} m_Father: {fileID: 339774397} - m_RootOrder: 13 + m_RootOrder: 14 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -1761,7 +1883,7 @@ RectTransform: - {fileID: 2010083454} - {fileID: 1081455630} m_Father: {fileID: 339774397} - m_RootOrder: 9 + m_RootOrder: 10 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -2914,7 +3036,7 @@ RectTransform: - {fileID: 175751363} - {fileID: 1904789319} m_Father: {fileID: 339774397} - m_RootOrder: 8 + m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -2951,7 +3073,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 339774397} - m_RootOrder: 6 + m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -4114,7 +4236,7 @@ GameObject: - component: {fileID: 1268276257} - component: {fileID: 1268276256} m_Layer: 5 - m_Name: Version + m_Name: VrmVersion m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -4441,7 +4563,7 @@ RectTransform: - {fileID: 1866921958} - {fileID: 1767669911} m_Father: {fileID: 339774397} - m_RootOrder: 5 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -4654,7 +4776,7 @@ RectTransform: - {fileID: 452923209} - {fileID: 2090837017} m_Father: {fileID: 339774397} - m_RootOrder: 12 + m_RootOrder: 13 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -4818,7 +4940,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 339774397} - m_RootOrder: 2 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -5394,7 +5516,7 @@ RectTransform: - {fileID: 62367395} - {fileID: 1037763549} m_Father: {fileID: 339774397} - m_RootOrder: 10 + m_RootOrder: 11 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -5563,30 +5685,29 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_version: {fileID: 1268276256} - m_open: {fileID: 2009818433} + m_openModel: {fileID: 2009818433} + m_openMotion: {fileID: 168425996} m_enableLipSync: {fileID: 935566650} m_enableAutoBlink: {fileID: 634488422} m_enableAutoExpression: {fileID: 1767738855} m_useUrpMaterial: {fileID: 1438613465} m_useAsync: {fileID: 602093299} - m_src: {fileID: 0} m_target: {fileID: 802105000} - Root: {fileID: 0} m_motion: {fileID: 4900000, guid: 08df5151e71aed748b13547492fb8b9a, type: 3} m_texts: - m_textModelTitle: {fileID: 1111491925} - m_textModelVersion: {fileID: 1045380263} - m_textModelAuthor: {fileID: 854014595} - m_textModelContact: {fileID: 587234270} - m_textModelReference: {fileID: 1181308133} + m_textModelTitle: {fileID: 1636340565} + m_textModelVersion: {fileID: 2105159133} + m_textModelAuthor: {fileID: 827174942} + m_textModelContact: {fileID: 1922159877} + m_textModelReference: {fileID: 806723450} m_thumbnail: {fileID: 800895694} - m_textPermissionAllowed: {fileID: 1322834811} - m_textPermissionViolent: {fileID: 1242458544} - m_textPermissionSexual: {fileID: 933018279} - m_textPermissionCommercial: {fileID: 852999696} - m_textPermissionOther: {fileID: 1289294209} - m_textDistributionLicense: {fileID: 1476033062} - m_textDistributionOther: {fileID: 1104290798} + m_textPermissionAllowed: {fileID: 1633219309} + m_textPermissionViolent: {fileID: 935554082} + m_textPermissionSexual: {fileID: 928757302} + m_textPermissionCommercial: {fileID: 773923920} + m_textPermissionOther: {fileID: 1172469240} + m_textDistributionLicense: {fileID: 1007924637} + m_textDistributionOther: {fileID: 1199975014} m_ui: ToggleMotionTPose: {fileID: 1791103380} ToggleMotionBVH: {fileID: 1311520910} @@ -5622,7 +5743,7 @@ RectTransform: - {fileID: 1166391799} - {fileID: 1140410864} m_Father: {fileID: 339774397} - m_RootOrder: 4 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -5912,6 +6033,87 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1922159875} m_CullTransparentMesh: 0 +--- !u!1 &1923525314 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1923525315} + - component: {fileID: 1923525317} + - component: {fileID: 1923525316} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1923525315 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1923525314} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 168425995} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1923525316 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1923525314} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: 'Open Motion + +' +--- !u!222 &1923525317 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1923525314} + m_CullTransparentMesh: 0 --- !u!1 &1954133884 GameObject: m_ObjectHideFlags: 0 @@ -6061,7 +6263,9 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: Open + m_Text: 'Open Model + +' --- !u!222 &1963417401 CanvasRenderer: m_ObjectHideFlags: 0 @@ -6083,7 +6287,7 @@ GameObject: - component: {fileID: 2009818434} - component: {fileID: 2009818433} m_Layer: 5 - m_Name: Open + m_Name: OpenModel m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 diff --git a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs index 2c8c9bf3a..aadfa0104 100644 --- a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs +++ b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs @@ -11,12 +11,15 @@ namespace UniVRM10.VRM10Viewer { public class VRM10ViewerUI : MonoBehaviour { - [Header("UI")] [SerializeField] Text m_version = default; + [Header("UI")] [SerializeField] - Button m_open = default; + Button m_openModel = default; + + [SerializeField] + Button m_openMotion = default; [SerializeField] Toggle m_enableLipSync = default; @@ -48,7 +51,7 @@ namespace UniVRM10.VRM10Viewer [Serializable] class TextFields { - [SerializeField, Header("Info")] + [SerializeField] Text m_textModelTitle = default; [SerializeField] Text m_textModelVersion = default; @@ -77,6 +80,28 @@ namespace UniVRM10.VRM10Viewer [SerializeField] Text m_textDistributionOther = default; + public void Reset() + { + var texts = GameObject.FindObjectsOfType(); + m_textModelTitle = texts.First(x => x.name == "Title"); + m_textModelVersion = texts.First(x => x.name == "Version"); + m_textModelAuthor = texts.First(x => x.name == "Author"); + m_textModelContact = texts.First(x => x.name == "Contact"); + m_textModelReference = texts.First(x => x.name == "Reference"); + + m_textPermissionAllowed = texts.First(x => x.name == "AllowedUser"); + m_textPermissionViolent = texts.First(x => x.name == "Violent"); + m_textPermissionSexual = texts.First(x => x.name == "Sexual"); + m_textPermissionCommercial = texts.First(x => x.name == "Commercial"); + m_textPermissionOther = texts.First(x => x.name == "Other"); + + m_textDistributionLicense = texts.First(x => x.name == "LicenseType"); + m_textDistributionOther = texts.First(x => x.name == "OtherLicense"); + + var images = GameObject.FindObjectsOfType(); + m_thumbnail = images.First(x => x.name == "RawImage"); + } + public void Start() { m_textModelTitle.text = ""; @@ -151,6 +176,16 @@ namespace UniVRM10.VRM10Viewer [SerializeField] ToggleGroup ToggleMotion = default; + public void Reset() + { + var toggles = GameObject.FindObjectsOfType(); + ToggleMotionTPose = toggles.First(x => x.name == "TPose"); + ToggleMotionBVH = toggles.First(x => x.name == "BVH"); + + var groups = GameObject.FindObjectsOfType(); + ToggleMotion = groups.First(x => x.name == "_Motion_"); + } + public bool IsBvhEnabled { get => ToggleMotion.ActiveToggles().FirstOrDefault() == ToggleMotionBVH; @@ -167,15 +202,21 @@ namespace UniVRM10.VRM10Viewer private void Reset() { var buttons = GameObject.FindObjectsOfType