From 7234430424c5565bc64c0ca3249e121bd440685a Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 28 Nov 2024 14:00:47 +0900 Subject: [PATCH 01/43] m_Script --- Assets/VRM10/Editor/Vrm10InstanceEditor.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Assets/VRM10/Editor/Vrm10InstanceEditor.cs b/Assets/VRM10/Editor/Vrm10InstanceEditor.cs index 7166bd9d5..b58789e68 100644 --- a/Assets/VRM10/Editor/Vrm10InstanceEditor.cs +++ b/Assets/VRM10/Editor/Vrm10InstanceEditor.cs @@ -24,6 +24,7 @@ namespace UniVRM10 Vrm10Instance m_instance; + SerializedProperty m_script; SerializedProperty m_vrmObject; SerializedProperty m_updateType; @@ -41,6 +42,7 @@ namespace UniVRM10 void OnEnable() { m_instance = (Vrm10Instance)target; + m_script = serializedObject.FindProperty("m_Script"); m_vrmObject = serializedObject.FindProperty(nameof(m_instance.Vrm)); m_updateType = serializedObject.FindProperty(nameof(m_instance.UpdateType)); @@ -254,6 +256,11 @@ namespace UniVRM10 public override void OnInspectorGUI() { + using (new EditorGUI.DisabledScope(true)) + { + EditorGUILayout.PropertyField(m_script); + } + if (m_instance.Vrm == null) { SetupVRM10Object(m_instance); From 97355c6f86e87238d1820ef7b7423bde48d409f3 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 28 Nov 2024 16:10:18 +0900 Subject: [PATCH 02/43] =?UTF-8?q?VisualElement=20TabView=20=E3=82=82?= =?UTF-8?q?=E3=81=A9=E3=81=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/VRM10/Editor/Vrm10InstanceEditor.cs | 84 +++++++++++----------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/Assets/VRM10/Editor/Vrm10InstanceEditor.cs b/Assets/VRM10/Editor/Vrm10InstanceEditor.cs index b58789e68..ecfadda39 100644 --- a/Assets/VRM10/Editor/Vrm10InstanceEditor.cs +++ b/Assets/VRM10/Editor/Vrm10InstanceEditor.cs @@ -5,6 +5,9 @@ using UniGLTF; using UniGLTF.Utils; using UnityEditor; using UnityEngine; +using UnityEngine.UIElements; +using UnityEditor.UIElements; + namespace UniVRM10 { @@ -20,8 +23,6 @@ namespace UniVRM10 SpringBone, } - Tab m_tab; - Vrm10Instance m_instance; SerializedProperty m_script; @@ -251,57 +252,60 @@ namespace UniVRM10 } } - - static readonly string[] Tabs = ((Tab[])Enum.GetValues(typeof(Tab))).Select(x => x.ToString()).ToArray(); - - public override void OnInspectorGUI() + public override VisualElement CreateInspectorGUI() { - using (new EditorGUI.DisabledScope(true)) + var root = new VisualElement(); + + root.Bind(serializedObject); { - EditorGUILayout.PropertyField(m_script); + var s = new PropertyField { bindingPath = "m_Script" }; + s.SetEnabled(false); + root.Add(s); } - if (m_instance.Vrm == null) - { - SetupVRM10Object(m_instance); - } + var tabs = new EnumField("tab", default(Tab)); + root.Add(tabs); - var backup = GUI.enabled; - try + var body = new VisualElement(); + List<(Tab, VisualElement)> contents = new() { - GUI.enabled = true; - using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar)) + (Tab.VrmInstance, new IMGUIContainer(GUIVrmInstance)), + (Tab.LookAt, new IMGUIContainer(GUILookAt)), + (Tab.SpringBone, new IMGUIContainer(GUISpringBone)), + }; + foreach (var (tab, content) in contents) + { + // content.visible = tab == Tab.VrmInstance; + content.style.display = tab == Tab.VrmInstance + ? DisplayStyle.Flex + : DisplayStyle.None + ; + body.Add(content); + } + root.Add(body); + + tabs.RegisterValueChangedCallback(e => + { + var selected = (Tab)e.newValue; + foreach (var (tab, content) in contents) { - m_tab = (Tab)GUILayout.Toolbar((int)m_tab, Tabs, new GUIStyle(EditorStyles.toolbarButton), GUI.ToolbarButtonSize.FitToContents); + // content.visible = tab == selected; + content.style.display = tab == selected + ? DisplayStyle.Flex + : DisplayStyle.None + ; } - } - finally - { - GUI.enabled = backup; - } + }); - switch (m_tab) - { - case Tab.VrmInstance: - GUIVrmInstance(); - break; - - case Tab.LookAt: - GUILookAt(); - break; - - case Tab.SpringBone: - GUISpringBone(); - break; - - default: - throw new Exception(); - } - // base.OnInspectorGUI(); + return root; } void GUIVrmInstance() { + if (m_instance.Vrm == null) + { + SetupVRM10Object(m_instance); + } serializedObject.Update(); EditorGUILayout.PropertyField(m_vrmObject); EditorGUILayout.PropertyField(m_updateType); From 1f55d0dcfbbe062992f9e07f2c3f79f56183dc21 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 28 Nov 2024 19:41:39 +0900 Subject: [PATCH 03/43] GUISpringBone use VisualElement --- .../SpringBone/VRM10SpringBoneDrawer.cs | 2 +- Assets/VRM10/Editor/Vrm10InstanceEditor.cs | 114 ++++++------------ 2 files changed, 40 insertions(+), 76 deletions(-) diff --git a/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneDrawer.cs b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneDrawer.cs index bcfca3265..2a05cf802 100644 --- a/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneDrawer.cs +++ b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneDrawer.cs @@ -8,7 +8,7 @@ namespace UniVRM10 { using static Vrm10InstanceSpringBone; - // [CustomPropertyDrawer(typeof(Spring))] + [CustomPropertyDrawer(typeof(Spring))] public class VRM10SpringBoneDrawer : PropertyDrawer { public override float GetPropertyHeight(SerializedProperty property, GUIContent label) diff --git a/Assets/VRM10/Editor/Vrm10InstanceEditor.cs b/Assets/VRM10/Editor/Vrm10InstanceEditor.cs index ecfadda39..e0e61e480 100644 --- a/Assets/VRM10/Editor/Vrm10InstanceEditor.cs +++ b/Assets/VRM10/Editor/Vrm10InstanceEditor.cs @@ -15,6 +15,8 @@ namespace UniVRM10 public class Vrm10InstanceEditor : Editor { const string SaveTitle = "New folder for vrm-1.0 assets..."; + const string SpringsPath = "SpringBone.Springs"; + const string CollidersPath = "SpringBone.ColliderGroups"; enum Tab { @@ -33,13 +35,6 @@ namespace UniVRM10 SerializedProperty m_lookatTarget; SerializedProperty m_lookatTargetType; - SerializedProperty m_colliderGroups; - SerializedProperty m_springs; - UnityEditorInternal.ReorderableList m_springList; - // int m_springListIndex = 0; - SerializedProperty m_springSelected; - SerializedProperty m_springSelectedJoints; - void OnEnable() { m_instance = (Vrm10Instance)target; @@ -51,39 +46,6 @@ namespace UniVRM10 m_drawLookatGizmo = serializedObject.FindProperty(nameof(m_instance.DrawLookAtGizmo)); m_lookatTarget = serializedObject.FindProperty(nameof(m_instance.LookAtTarget)); m_lookatTargetType = serializedObject.FindProperty(nameof(m_instance.LookAtTargetType)); - - m_colliderGroups = serializedObject.FindProperty($"{nameof(m_instance.SpringBone)}.{nameof(m_instance.SpringBone.ColliderGroups)}"); - m_springs = serializedObject.FindProperty($"{nameof(m_instance.SpringBone)}.{nameof(m_instance.SpringBone.Springs)}"); - m_springList = new(serializedObject, m_springs); - m_springList.drawHeaderCallback += rect => - { - EditorGUI.LabelField(rect, m_springs.displayName); - }; - Action updateSelected = (list) => - { - var index = list.index; - if (index < 0) - { - index = 0; - } - else if (index >= list.count) - { - index = list.count - 1; - } - if (list.index >= 0 && list.index < list.count) - { - m_springSelected = m_springs.GetArrayElementAtIndex(list.index); - m_springSelected.FindPropertyRelative("ColliderGroups").isExpanded = true; - m_springSelectedJoints = m_springSelected.FindPropertyRelative("Joints"); - m_springSelectedJoints.isExpanded = true; - } - else - { - m_springSelected = null; - } - }; - m_springList.onSelectCallback = new(updateSelected); - m_springList.onChangedCallback = new(updateSelected); } static VRM10Object CreateAsset(string path, Dictionary expressions, Vrm10Instance instance) @@ -263,7 +225,7 @@ namespace UniVRM10 root.Add(s); } - var tabs = new EnumField("tab", default(Tab)); + var tabs = new EnumField("select UI", default(Tab)); root.Add(tabs); var body = new VisualElement(); @@ -271,7 +233,7 @@ namespace UniVRM10 { (Tab.VrmInstance, new IMGUIContainer(GUIVrmInstance)), (Tab.LookAt, new IMGUIContainer(GUILookAt)), - (Tab.SpringBone, new IMGUIContainer(GUISpringBone)), + (Tab.SpringBone, GUISpringBone()), }; foreach (var (tab, content) in contents) { @@ -321,45 +283,47 @@ namespace UniVRM10 serializedObject.ApplyModifiedProperties(); } - void GUISpringBone() + VisualElement GUISpringBone() { - serializedObject.Update(); + var root = new VisualElement(); - EditorGUILayout.PropertyField(m_colliderGroups); - // EditorGUILayout.PropertyField(m_springs); - m_springList.DoLayoutList(); - - if (m_springSelected != null) + root.Add(new PropertyField { - EditorGUILayout.PropertyField(m_springSelected); + bindingPath = CollidersPath, + }); - if (m_springSelectedJoints.arraySize > 0 && GUILayout.Button("create joints to children")) + var springs = new ListView + { + bindingPath = SpringsPath, + makeItem = () => { - if (EditorUtility.DisplayDialog("auto joints", - "先頭の joint の子孫をリストに追加します。\n既存のリストは上書きされます。", - "ok", - "cancel")) - { - var joints = m_springSelectedJoints; - var root = (VRM10SpringBoneJoint)joints.GetArrayElementAtIndex(0).objectReferenceValue; - joints.ClearArray(); - int i = 0; - // 0 - joints.InsertArrayElementAtIndex(i); - joints.GetArrayElementAtIndex(i).objectReferenceValue = root; - ++i; - // 1... - foreach (var joint in MakeJointsRecursive(root)) - { - joints.InsertArrayElementAtIndex(i); - joints.GetArrayElementAtIndex(i).objectReferenceValue = joint; - ++i; - } - } - } - } + return new Label(); + }, + bindItem = (v, i) => + { + var prop = serializedObject.FindProperty($"{SpringsPath}.Array.data[{i}].Name"); + (v as Label).BindProperty(prop); + }, + }; + springs.headerTitle = "Springs"; + springs.showFoldoutHeader = true; + springs.showAddRemoveFooter = true; + root.Add(springs); - serializedObject.ApplyModifiedProperties(); + var selected = new PropertyField(); + springs.selectedIndicesChanged += (e) => + { + var values = e.ToArray(); + if (values.Length > 0) + { + var path = $"{SpringsPath}.Array.data[{values[0]}]"; + var prop = serializedObject.FindProperty(path); + selected.BindProperty(prop); + } + }; + root.Add(selected); + + return root; } static IEnumerable MakeJointsRecursive(VRM10SpringBoneJoint parent) From 7ec1951f3716b5772db06c7614f74bdc52baac85 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 28 Nov 2024 20:06:57 +0900 Subject: [PATCH 04/43] highlight selected spring --- Assets/VRM10/Editor/Vrm10InstanceEditor.cs | 37 ++++++++++++++++------ 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/Assets/VRM10/Editor/Vrm10InstanceEditor.cs b/Assets/VRM10/Editor/Vrm10InstanceEditor.cs index e0e61e480..2b1125235 100644 --- a/Assets/VRM10/Editor/Vrm10InstanceEditor.cs +++ b/Assets/VRM10/Editor/Vrm10InstanceEditor.cs @@ -35,6 +35,8 @@ namespace UniVRM10 SerializedProperty m_lookatTarget; SerializedProperty m_lookatTargetType; + ListView m_springs; + void OnEnable() { m_instance = (Vrm10Instance)target; @@ -287,12 +289,9 @@ namespace UniVRM10 { var root = new VisualElement(); - root.Add(new PropertyField - { - bindingPath = CollidersPath, - }); + root.Add(new PropertyField { bindingPath = CollidersPath }); - var springs = new ListView + m_springs = new ListView { bindingPath = SpringsPath, makeItem = () => @@ -305,13 +304,13 @@ namespace UniVRM10 (v as Label).BindProperty(prop); }, }; - springs.headerTitle = "Springs"; - springs.showFoldoutHeader = true; - springs.showAddRemoveFooter = true; - root.Add(springs); + m_springs.headerTitle = "Springs"; + m_springs.showFoldoutHeader = true; + m_springs.showAddRemoveFooter = true; + root.Add(m_springs); var selected = new PropertyField(); - springs.selectedIndicesChanged += (e) => + m_springs.selectedIndicesChanged += (e) => { var values = e.ToArray(); if (values.Length > 0) @@ -349,8 +348,26 @@ namespace UniVRM10 public void OnSceneGUI() { + HandleUtility.Repaint(); + // 親指のガイド DrawThumbGuide(target as Vrm10Instance); + + // 選択中の SpringBone + if (m_springs != null && m_springs.selectedIndex >= 0 && m_springs.selectedIndex < m_instance.SpringBone.Springs.Count) + { + Handles.color = Color.red; + var selected = m_instance.SpringBone.Springs[m_springs.selectedIndex]; + for (int i = 1; i < selected.Joints.Count; ++i) + { + var head = selected.Joints[i - 1]; + var tail = selected.Joints[i]; + if (head != null && tail != null) + { + Handles.DrawLine(head.transform.position, tail.transform.position); + } + } + } } static void DrawThumbGuide(Vrm10Instance instance) From c75dd199a50adcf9f3add24af8d4810511f52dc0 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 29 Nov 2024 03:24:02 +0900 Subject: [PATCH 05/43] UseJob default true --- .../ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs index 9bfa68d8b..c90d025b7 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using UnityEngine; -using UniVRM10; + namespace UniVRM10.ClothWarp.Components { @@ -17,7 +17,7 @@ namespace UniVRM10.ClothWarp.Components public List Cloths = new(); [SerializeField] - public bool UseJob; + public bool UseJob = true; IVrm10SpringBoneRuntime m_runtime; public IVrm10SpringBoneRuntime CreateSpringBoneRuntime() From ffb1f54bdd20a05abb9a8bb53c074397cca5daab Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 29 Nov 2024 03:24:14 +0900 Subject: [PATCH 06/43] update RotateParticleRuntimeProviderEditor --- .../RotateParticleRuntimeProviderEditor.cs | 81 ++++++++++++------- 1 file changed, 50 insertions(+), 31 deletions(-) diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/RotateParticleRuntimeProviderEditor.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/RotateParticleRuntimeProviderEditor.cs index f1c12601a..320595292 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/RotateParticleRuntimeProviderEditor.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/RotateParticleRuntimeProviderEditor.cs @@ -1,7 +1,6 @@ -using System.Linq; +using UnityEngine.UIElements; using UnityEditor; -using UnityEngine; -using UniVRM10; +using UnityEditor.UIElements; namespace UniVRM10.ClothWarp.Components @@ -11,58 +10,78 @@ namespace UniVRM10.ClothWarp.Components { const string FROM_VRM10_MENU = "Replace VRM10 Springs to ClothWarp Warps"; - [MenuItem(FROM_VRM10_MENU, true)] - public static bool IsFromVrm10() + ClothWarpRuntimeProvider _target; + Vrm10Instance _vrm; + + void OnEnable() { - var go = Selection.activeGameObject; - if (go == null) + _target = (ClothWarpRuntimeProvider)target; + if (_target != null) { - return false; + _vrm = _target.GetComponent(); } - return go.GetComponent() != null; } - public override void OnInspectorGUI() + public override VisualElement CreateInspectorGUI() { - var provider = target as ClothWarpRuntimeProvider; - if (provider == null) + var root = new VisualElement(); + root.Bind(serializedObject); { - return; + var s = new PropertyField { bindingPath = "m_Script" }; + s.SetEnabled(false); + root.Add(s); } - var instance = provider.GetComponent(); - using (new EditorGUI.DisabledScope(instance == null)) + root.Add(new PropertyField { bindingPath = nameof(_target.Warps) }); + root.Add(new PropertyField { bindingPath = nameof(_target.Cloths) }); + { - if (GUILayout.Button("Replace VRM10 Springs to ClothWarp Warps")) + var setup = new Foldout { text = "Setup" }; + + var from_vrm10 = new Button { text = "Replace VRM10 Springs to ClothWarp Warps" }; + setup.Add(from_vrm10); + from_vrm10.RegisterCallback(e => { Undo.IncrementCurrentGroup(); Undo.SetCurrentGroupName(FROM_VRM10_MENU); var undo = Undo.GetCurrentGroup(); - Undo.RegisterCompleteObjectUndo(instance, "RegisterCompleteObjectUndo"); - ClothWarpRuntimeProvider.FromVrm10(instance, Undo.AddComponent, Undo.DestroyObjectImmediate); - Undo.RegisterFullObjectHierarchyUndo(instance.gameObject, "RegisterFullObjectHierarchyUndo"); + Undo.RegisterCompleteObjectUndo(_vrm, "RegisterCompleteObjectUndo"); + ClothWarpRuntimeProvider.FromVrm10(_vrm, Undo.AddComponent, Undo.DestroyObjectImmediate); + Undo.RegisterFullObjectHierarchyUndo(_vrm.gameObject, "RegisterFullObjectHierarchyUndo"); - Undo.RegisterCompleteObjectUndo(provider, "RegisterCompleteObjectUndo"); - provider.Reset(); + Undo.RegisterCompleteObjectUndo(_target, "RegisterCompleteObjectUndo"); + _target.Reset(); Undo.CollapseUndoOperations(undo); - } - } + }); - using (new EditorGUI.DisabledScope(instance == null || !Application.isPlaying)) - { - if (GUILayout.Button("RestoreInitialTransform")) + var reload = new Button { text = "Reload" }; + setup.Add(reload); + reload.RegisterCallback(e => { - instance.Runtime.SpringBone.RestoreInitialTransform(); - } + _target.Reset(); + }); + + root.Add(setup); } - if (GUILayout.Button("Reset")) { - provider.Reset(); + // runtime: reset button + var runtime = new Foldout { text = "Runtime" }; + root.Add(runtime); + + var button = new Button + { + text = "RestoreInitialTransform", + }; + runtime.Add(button); + button.RegisterCallback((e) => + { + _vrm.Runtime.SpringBone.RestoreInitialTransform(); + }); } - base.OnInspectorGUI(); + return root; } } } \ No newline at end of file From 6018af0a4e15ccf78d861bd19ca2da0813d18cf3 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 29 Nov 2024 03:58:24 +0900 Subject: [PATCH 07/43] fix ClothWarpRoot.OnValidate --- .../ClothWarp/Runtime/Components/ClothWarpRoot.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRoot.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRoot.cs index fa3b708c0..456a8c3a8 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRoot.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRoot.cs @@ -4,7 +4,6 @@ using System.Linq; using UniGLTF.SpringBoneJobs.Blittables; using UnityEngine; using UnityEngine.UIElements; -using UniVRM10; namespace UniVRM10.ClothWarp.Components @@ -100,7 +99,18 @@ namespace UniVRM10.ClothWarp.Components void OnValidate() { - m_particles = GetComponentsInChildren().Skip(1).Select(x => new Particle(x)).ToList(); + var backup = m_particles.ToDictionary(x => x.Transform, x => x); + m_particles = GetComponentsInChildren().Skip(1).Select(x => + { + foreach (var particle in m_particles) + { + if (particle.Transform == x) + { + return particle; + } + } + return new Particle(x); + }).ToList(); m_map.Clear(); for (int i = 0; i < m_particles.Count; ++i) { From 9773b0c915f79a42a868c22fa4948bf077b6d21c Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 29 Nov 2024 03:58:34 +0900 Subject: [PATCH 08/43] rename --- .../Editor/{WarpRootEditor.cs => ClothWarpRootEditor.cs} | 2 +- .../{WarpRootEditor.cs.meta => ClothWarpRootEditor.cs.meta} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/{WarpRootEditor.cs => ClothWarpRootEditor.cs} (99%) rename Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/{WarpRootEditor.cs.meta => ClothWarpRootEditor.cs.meta} (100%) diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/WarpRootEditor.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs similarity index 99% rename from Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/WarpRootEditor.cs rename to Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs index 44f81cae6..2af75f659 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/WarpRootEditor.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs @@ -10,7 +10,7 @@ using UniVRM10; namespace UniVRM10.ClothWarp.Components { [CustomEditor(typeof(ClothWarpRoot))] - class WarpRootEditor : Editor + class ClothWarpRootEditor : Editor { private ClothWarpRoot m_target; private Vrm10Instance m_vrm; diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/WarpRootEditor.cs.meta b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs.meta similarity index 100% rename from Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/WarpRootEditor.cs.meta rename to Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs.meta From 95d5576cc81c91099d19189708e787041bb6514a Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 29 Nov 2024 11:06:47 +0900 Subject: [PATCH 09/43] fix StrandCollisionJob --- .../ClothSample/ClothWarp/Runtime/Jobs/Collision.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Collision.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Collision.cs index 1f572cd4f..71966a434 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Collision.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Collision.cs @@ -59,8 +59,8 @@ namespace UniVRM10.ClothWarp.Jobs pos += l.GetDelta(c.radius); } } - StrandCollision[particleIndex] = pos; } + StrandCollision[particleIndex] = pos; } } @@ -312,8 +312,8 @@ namespace UniVRM10.ClothWarp.Jobs } else { - NextPosition[particleIndex] = StrandCollision[particleIndex]; + NextPosition[particleIndex] = StrandCollision[particleIndex]; + } } } - } } \ No newline at end of file From d21ac212d9e93966c551ae599042415f703b40bb Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 29 Nov 2024 13:40:01 +0900 Subject: [PATCH 10/43] Replace split to Load and Clear --- .../ClothSample/ClothViewer/ClothViewerUI.cs | 3 +- .../ClothWarp/Editor/ClothWarpRootEditor.cs | 38 +++++----------- .../RotateParticleRuntimeProviderEditor.cs | 44 +++++++++++++++---- .../ClothWarp/Runtime/ClothWarpRuntime.cs | 3 ++ .../Components/ClothWarpRuntimeProvider.cs | 10 +---- .../Runtime/Jobs/ClothWarpJobRuntime.cs | 12 ++++- .../ClothWarp/Runtime/Jobs/Particle.cs | 13 +++--- 7 files changed, 72 insertions(+), 51 deletions(-) diff --git a/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs b/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs index 5473dc515..7edcdfcca 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs @@ -402,8 +402,7 @@ namespace UniVRM10.Cloth.Viewer else { ClothWarpRuntimeProvider.FromVrm10(vrm, - go => go.AddComponent(), - o => GameObject.DestroyImmediate(o)); + go => go.AddComponent()); } if (animator.GetBoneTransform(HumanBodyBones.Hips) is var hips) diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs index 2af75f659..4b902d18b 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs @@ -27,26 +27,6 @@ namespace UniVRM10.ClothWarp.Components m_vrm = m_target.GetComponentInParent(); } - // public override void OnInspectorGUI() - // { - // var n = EditorUtility.GetDirtyCount(m_target.GetInstanceID()); - // base.OnInspectorGUI(); - // if (n != EditorUtility.GetDirtyCount(m_target.GetInstanceID())) - // { - // if (m_vrm != null) - // { - // if (Application.isPlaying) - // { - // m_vrm.Runtime.SpringBone.SetJointLevel(m_target.transform, m_target.BaseSettings); - // foreach (var p in m_target.Particles) - // { - // m_vrm.Runtime.SpringBone.SetJointLevel(p.Transform, p.GetSettings(m_target.BaseSettings)); - // } - // } - // } - // } - // } - void BindColumn(string title, int width, Func makeVisualELmeent, Func enableFunc, string subpath) where T : BindableElement { m_treeview.columns.Add(new Column @@ -116,15 +96,19 @@ namespace UniVRM10.ClothWarp.Components private void OnValueChanged(SerializedObject so) { - Debug.Log("Name changed: " + so.targetObject.name); - // var nameProperty = so.FindProperty("m_Name"); + if (m_vrm != null) + { + if (Application.isPlaying) + { + m_vrm.Runtime.SpringBone.SetJointLevel(m_target.transform, m_target.BaseSettings); + foreach (var p in m_target.Particles) + { + m_vrm.Runtime.SpringBone.SetJointLevel(p.Transform, p.Settings); + } + } + } - // if (nameProperty.stringValue.Contains(" ")) - // _textField.style.backgroundColor = Color.red; - // else - // _textField.style.backgroundColor = StyleKeyword.Null; m_treeview.RefreshItems(); - // m_treeview.SetRootItems(m_target.m_rootitems); Repaint(); } diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/RotateParticleRuntimeProviderEditor.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/RotateParticleRuntimeProviderEditor.cs index 320595292..5b935b7e9 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/RotateParticleRuntimeProviderEditor.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/RotateParticleRuntimeProviderEditor.cs @@ -8,8 +8,6 @@ namespace UniVRM10.ClothWarp.Components [CustomEditor(typeof(ClothWarpRuntimeProvider))] public class RotateParticleRuntimeProviderEditor : Editor { - const string FROM_VRM10_MENU = "Replace VRM10 Springs to ClothWarp Warps"; - ClothWarpRuntimeProvider _target; Vrm10Instance _vrm; @@ -37,21 +35,51 @@ namespace UniVRM10.ClothWarp.Components { var setup = new Foldout { text = "Setup" }; - var from_vrm10 = new Button { text = "Replace VRM10 Springs to ClothWarp Warps" }; + var from_vrm10 = new Button { text = "Load VRM10 Springs to ClothWarp Warps" }; setup.Add(from_vrm10); from_vrm10.RegisterCallback(e => { Undo.IncrementCurrentGroup(); - Undo.SetCurrentGroupName(FROM_VRM10_MENU); + Undo.SetCurrentGroupName("Load Vrm-1.0 Springs to ClothWarp Warps"); + var undo = Undo.GetCurrentGroup(); + + // attach ClothWarp from VRM10Instance.Springs + ClothWarpRuntimeProvider.FromVrm10(_vrm, Undo.AddComponent); + Undo.RegisterFullObjectHierarchyUndo(_vrm.gameObject, "RegisterFullObjectHierarchyUndo"); + + // update ClothWarpRuntimeProvider + Undo.RegisterCompleteObjectUndo(_target, "RegisterCompleteObjectUndo"); + _target.Reset(); + + Undo.CollapseUndoOperations(undo); + }); + + var clear_vrm10_springs = new Button { text = "Clear Vrm-1.0 springs" }; + setup.Add(clear_vrm10_springs); + clear_vrm10_springs.RegisterCallback(e => + { + Undo.IncrementCurrentGroup(); + Undo.SetCurrentGroupName("Clear VRM10 Srpings"); var undo = Undo.GetCurrentGroup(); Undo.RegisterCompleteObjectUndo(_vrm, "RegisterCompleteObjectUndo"); - ClothWarpRuntimeProvider.FromVrm10(_vrm, Undo.AddComponent, Undo.DestroyObjectImmediate); + foreach (var spring in _vrm.SpringBone.Springs) + { + if (spring != null) + { + foreach (var joint in spring.Joints) + { + if (joint != null) + { + Undo.DestroyObjectImmediate(joint); + } + } + } + spring.Joints.Clear(); + } + _vrm.SpringBone.Springs.Clear(); Undo.RegisterFullObjectHierarchyUndo(_vrm.gameObject, "RegisterFullObjectHierarchyUndo"); - Undo.RegisterCompleteObjectUndo(_target, "RegisterCompleteObjectUndo"); - _target.Reset(); - Undo.CollapseUndoOperations(undo); }); diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/ClothWarpRuntime.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/ClothWarpRuntime.cs index 63888a4d6..ed13969c8 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/ClothWarpRuntime.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/ClothWarpRuntime.cs @@ -11,6 +11,9 @@ using UnityEngine; namespace UniVRM10.ClothWarp { + /// + /// プロトタイプ。非 job + /// public class ClothWarpRuntime : IVrm10SpringBoneRuntime { Vrm10Instance _vrm; diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs index c90d025b7..6c238e2d3 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Components/ClothWarpRuntimeProvider.cs @@ -45,8 +45,7 @@ namespace UniVRM10.ClothWarp.Components } public static void FromVrm10(Vrm10Instance instance, - Func addWarp, - Action deleteObject) + Func addWarp) { foreach (var spring in instance.SpringBone.Springs) { @@ -64,7 +63,6 @@ namespace UniVRM10.ClothWarp.Components var warp = root_joint.GetComponent(); if (warp == null) { - // var warp = Undo.AddComponent(root_joint); warp = addWarp(root_joint); var joints = spring.Joints.Where(x => x != null).ToArray(); for (int i = 0; i < joints.Length; ++i) @@ -76,7 +74,7 @@ namespace UniVRM10.ClothWarp.Components gravityDir = joint.m_gravityDir, gravityPower = joint.m_gravityPower, // mod - stiffnessForce = joint.m_stiffnessForce * 6, + stiffnessForce = joint.m_stiffnessForce /* * 6*/, }; if (i == 0) { @@ -97,14 +95,10 @@ namespace UniVRM10.ClothWarp.Components warp.SetSettings(joint.transform, settings); } } - // Undo.DestroyObjectImmediate(joint); - deleteObject(joint); } - spring.Joints.Clear(); warp.ColliderGroups = spring.ColliderGroups.ToList(); } } - instance.SpringBone.Springs.Clear(); } } } \ No newline at end of file diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/ClothWarpJobRuntime.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/ClothWarpJobRuntime.cs index b05e25ce3..23fc6ded3 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/ClothWarpJobRuntime.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/ClothWarpJobRuntime.cs @@ -12,6 +12,9 @@ using UniVRM10; namespace UniVRM10.ClothWarp.Jobs { + /// + /// Job 版 + /// public class ClothWarpJobRuntime : IVrm10SpringBoneRuntime { Vrm10Instance _vrm; @@ -129,7 +132,7 @@ namespace UniVRM10.ClothWarp.Jobs _currentColliders = new(_colliderTransforms.Count, Allocator.Persistent); // - // warps + // warps => particles // _transforms = new(); List info = new(); @@ -334,6 +337,13 @@ namespace UniVRM10.ClothWarp.Jobs }.Schedule(_info.Length, 128, handle); } + // 親子の長さで拘束. TODO: ApplyRotationJob と合体 + handle = new ParentLengthConstraintJob + { + Warps = _warps, + Info = _info, + NextPositions = _nextPositions, + }.Schedule(_warps.Length, 16, handle); // NextPositions から NextRotations を作る handle = new ApplyRotationJob { diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Particle.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Particle.cs index c85550f8a..4836935a5 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Particle.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Particle.cs @@ -77,6 +77,7 @@ namespace UniVRM10.ClothWarp.Jobs public void Execute(int particleIndex) { + const float FACTOR = 6.0f; var particle = Info[particleIndex]; if (particle.TransformType.Movable()) { @@ -85,13 +86,15 @@ namespace UniVRM10.ClothWarp.Jobs var parent = Info[parentIndex]; var parentParentRotation = CurrentTransforms[parent.ParentIndex].Rotation; - var external = (particle.Settings.gravityDir * particle.Settings.gravityPower + Frame.Force) * Frame.DeltaTime; + var velocity = (CurrentPositions[particleIndex] - PrevPositions[particleIndex]) * (1.0f - particle.Settings.dragForce); + var resilience = parentParentRotation * parent.InitLocalRotation * particle.InitLocalPosition * + particle.Settings.stiffnessForce * FACTOR; // 親の回転による子ボーンの移動目標 + var external = particle.Settings.gravityDir * particle.Settings.gravityPower + Frame.Force; var newPosition = CurrentPositions[particleIndex] - + (CurrentPositions[particleIndex] - PrevPositions[particleIndex]) * (1.0f - particle.Settings.dragForce) - + parentParentRotation * parent.InitLocalRotation * particle.InitLocalPosition * - particle.Settings.stiffnessForce * Frame.DeltaTime // 親の回転による子ボーンの移動目標 - + external + + velocity + + resilience * Frame.DeltaTime + + external * Frame.DeltaTime ; NextPositions[particleIndex] = newPosition; From 9f1977d76f3d5fd75e9fcf4b7a6e294997d982d3 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 29 Nov 2024 14:21:06 +0900 Subject: [PATCH 11/43] fix factor. add cloth to hips --- .../ClothSample/ClothViewer/ClothViewer.unity | 320 +++++++++++++++++- .../ClothSample/ClothViewer/ClothViewerUI.cs | 17 +- .../Components/ClothWarpRuntimeProvider.cs | 7 +- .../Runtime/Jobs/ClothWarpJobRuntime.cs | 6 +- .../ClothWarp/Runtime/Jobs/Particle.cs | 3 +- 5 files changed, 339 insertions(+), 14 deletions(-) diff --git a/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewer.unity b/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewer.unity index 75d5db057..d6abc2f6b 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewer.unity +++ b/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewer.unity @@ -402,7 +402,7 @@ MonoBehaviour: onValueChanged: m_PersistentCalls: m_Calls: [] - m_IsOn: 0 + m_IsOn: 1 --- !u!1 &153452228 GameObject: m_ObjectHideFlags: 0 @@ -686,6 +686,92 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 168425994} m_CullTransparentMesh: 0 +--- !u!1 &172483632 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 172483633} + - component: {fileID: 172483634} + m_Layer: 5 + m_Name: AddClothToHips + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &172483633 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 172483632} + 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_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1472853923} + - {fileID: 1724807119} + m_Father: {fileID: 339774397} + 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: 20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &172483634 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 172483632} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9085046f02f69544eb97fd06b6048fe2, 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: 1472853924} + toggleTransition: 1 + graphic: {fileID: 1236232219} + m_Group: {fileID: 0} + onValueChanged: + m_PersistentCalls: + m_Calls: [] + m_IsOn: 1 --- !u!1 &175751362 GameObject: m_ObjectHideFlags: 0 @@ -1407,6 +1493,7 @@ RectTransform: - {fileID: 1767706907} - {fileID: 947409974} - {fileID: 135168672} + - {fileID: 172483633} - {fileID: 2144476967} - {fileID: 1194499280} - {fileID: 153452229} @@ -5027,6 +5114,81 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1215781541} m_CullTransparentMesh: 0 +--- !u!1 &1236232217 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1236232218} + - component: {fileID: 1236232220} + - component: {fileID: 1236232219} + m_Layer: 5 + m_Name: Checkmark + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1236232218 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1236232217} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1472853923} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 20, y: 20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1236232219 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1236232217} + 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: 10901, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 0 + 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 &1236232220 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1236232217} + m_CullTransparentMesh: 0 --- !u!1 &1242458542 GameObject: m_ObjectHideFlags: 0 @@ -6228,6 +6390,82 @@ MonoBehaviour: m_PersistentCalls: m_Calls: [] m_IsOn: 0 +--- !u!1 &1472853922 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1472853923} + - component: {fileID: 1472853925} + - component: {fileID: 1472853924} + m_Layer: 5 + m_Name: Background + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1472853923 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1472853922} + 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_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1236232218} + m_Father: {fileID: 172483633} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 10, y: -10} + m_SizeDelta: {x: 20, y: 20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1472853924 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1472853922} + 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 &1472853925 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1472853922} + m_CullTransparentMesh: 0 --- !u!1 &1476033060 GameObject: m_ObjectHideFlags: 0 @@ -6774,6 +7012,85 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1684483641} m_CullTransparentMesh: 0 +--- !u!1 &1724807118 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1724807119} + - component: {fileID: 1724807121} + - component: {fileID: 1724807120} + m_Layer: 5 + m_Name: Label + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1724807119 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1724807118} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 172483633} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 9, y: -0.5} + m_SizeDelta: {x: -28, y: -3} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1724807120 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1724807118} + 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: 0 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Add cloth to Hips +--- !u!222 &1724807121 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1724807118} + m_CullTransparentMesh: 0 --- !u!1 &1761414315 GameObject: m_ObjectHideFlags: 0 @@ -7224,6 +7541,7 @@ MonoBehaviour: m_openModel: {fileID: 2009818433} m_showBoxMan: {fileID: 1767706908} m_useJob: {fileID: 135168673} + m_addClothToHips: {fileID: 172483634} m_reconstructSprngBone: {fileID: 2144476968} m_resetSpringBone: {fileID: 1194499281} m_pauseSpringBone: {fileID: 153452230} diff --git a/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs b/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs index 7edcdfcca..a25670807 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs @@ -21,6 +21,7 @@ namespace UniVRM10.Cloth.Viewer [Header("Cloth")] [SerializeField] Toggle m_useJob = default; + [SerializeField] Toggle m_addClothToHips = default; [SerializeField] Button m_reconstructSprngBone = default; [SerializeField] Button m_resetSpringBone = default; [SerializeField] Toggle m_pauseSpringBone = default; @@ -61,6 +62,7 @@ namespace UniVRM10.Cloth.Viewer m_showBoxMan = map.Get("ShowBoxMan"); m_useJob = map.Get("UseJob"); + m_addClothToHips = map.Get("AddClothToHips"); m_reconstructSprngBone = map.Get