diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs index c51a2b7ae..1df39e720 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Editor/ClothWarpRootEditor.cs @@ -154,8 +154,18 @@ namespace UniVRM10.ClothWarp.Components p = m_target.GetParticleFromTransform(p.Transform); var t = p.Transform; Handles.color = Color.green; - Handles.SphereHandleCap(t.GetInstanceID(), t.position, t.rotation, p.Settings.Radius * 2, EventType.Repaint); + Handles.SphereHandleCap(t.GetControlId(), t.position, t.rotation, p.Settings.Radius * 2, EventType.Repaint); } } } + + static class ClothWarpRootEditorExtensions + { + internal static int GetControlId(this Component component) +#if UNITY_6000_5_OR_NEWER + => component.GetEntityId().GetHashCode(); +#else + => component.GetInstanceID(); +#endif + } } \ No newline at end of file diff --git a/Packages/UniGLTF/Editor/UniHumanoid/MuscleInspectorEditor.cs b/Packages/UniGLTF/Editor/UniHumanoid/MuscleInspectorEditor.cs index 2c698ddee..dddc37da9 100644 --- a/Packages/UniGLTF/Editor/UniHumanoid/MuscleInspectorEditor.cs +++ b/Packages/UniGLTF/Editor/UniHumanoid/MuscleInspectorEditor.cs @@ -4,6 +4,11 @@ using System.Collections.Generic; using UnityEditor; using UnityEditor.IMGUI.Controls; using UnityEngine; +#if UNITY_6000_5_OR_NEWER +using TreeView = UnityEditor.IMGUI.Controls.TreeView; +using TreeViewItem = UnityEditor.IMGUI.Controls.TreeViewItem; +using TreeViewState = UnityEditor.IMGUI.Controls.TreeViewState; +#endif namespace UniHumanoid { @@ -183,7 +188,7 @@ namespace UniHumanoid } // inside class BoneTreeView : TreeView - protected override void RowGUI(UnityEditor.IMGUI.Controls.TreeView.RowGUIArgs args) + protected override void RowGUI(RowGUIArgs args) { for (int i = 0; i < args.GetNumVisibleColumns(); ++i) { @@ -191,7 +196,7 @@ namespace UniHumanoid } } - void CellGUI(Rect cellRect, int index, ref UnityEditor.IMGUI.Controls.TreeView.RowGUIArgs args) + void CellGUI(Rect cellRect, int index, ref RowGUIArgs args) { CenterRectUsingSingleLineHeight(ref cellRect); diff --git a/Packages/VRM10/Editor/Components/SpringBone/SelectedGUI.cs b/Packages/VRM10/Editor/Components/SpringBone/SelectedGUI.cs index 6eee18938..9185d149d 100644 --- a/Packages/VRM10/Editor/Components/SpringBone/SelectedGUI.cs +++ b/Packages/VRM10/Editor/Components/SpringBone/SelectedGUI.cs @@ -81,10 +81,24 @@ namespace UniVRM10 if (isFocused) { + bool refresh = false; +#if UNITY_6000_5_OR_NEWER + var id = element.objectReferenceValue.GetEntityId(); + if (id != VRM10SpringBoneCollider.SelectedEntityId) + { + VRM10SpringBoneCollider.SelectedEntityId = id; + refresh = true; + } +#else var id = element.objectReferenceValue.GetInstanceID(); if (id != VRM10SpringBoneCollider.SelectedGuid) { VRM10SpringBoneCollider.SelectedGuid = id; + refresh = true; + } +#endif + if (refresh) + { SceneView.RepaintAll(); EditorUtility.SetDirty(element.objectReferenceValue); } diff --git a/Packages/VRM10/Editor/Components/SpringBone/SpringBoneTreeView.cs b/Packages/VRM10/Editor/Components/SpringBone/SpringBoneTreeView.cs index 03ec1f6d6..0b1e44333 100644 --- a/Packages/VRM10/Editor/Components/SpringBone/SpringBoneTreeView.cs +++ b/Packages/VRM10/Editor/Components/SpringBone/SpringBoneTreeView.cs @@ -1,7 +1,13 @@ using System.Collections.Generic; using UnityEditor; -using UnityEditor.IMGUI.Controls; using UnityEngine; +#if UNITY_6000_5_OR_NEWER +using TreeView = UnityEditor.IMGUI.Controls.TreeView; +using TreeViewItem = UnityEditor.IMGUI.Controls.TreeViewItem; +using TreeViewState = UnityEditor.IMGUI.Controls.TreeViewState; +#else +using UnityEditor.IMGUI.Controls; +#endif namespace UniVRM10 { @@ -254,20 +260,20 @@ namespace UniVRM10 { case VRM10SpringBoneColliderTypes.Sphere: // Handles.color = Color.magenta; - Handles.SphereHandleCap(collider.GetInstanceID(), collider.Offset, Quaternion.identity, collider.Radius * 2, Event.current.type); + Handles.SphereHandleCap(collider.GetControlId(), collider.Offset, Quaternion.identity, collider.Radius * 2, Event.current.type); break; case VRM10SpringBoneColliderTypes.Capsule: // Handles.color = Color.cyan; - Handles.SphereHandleCap(collider.GetInstanceID(), collider.Offset, Quaternion.identity, collider.Radius * 2, Event.current.type); - Handles.SphereHandleCap(collider.GetInstanceID(), collider.Tail, Quaternion.identity, collider.Radius * 2, Event.current.type); + Handles.SphereHandleCap(collider.GetControlId(), collider.Offset, Quaternion.identity, collider.Radius * 2, Event.current.type); + Handles.SphereHandleCap(collider.GetControlId(), collider.Tail, Quaternion.identity, collider.Radius * 2, Event.current.type); Handles.DrawLine(collider.Offset, collider.Tail); break; } Handles.matrix = Matrix4x4.identity; } - var isHover = HandleUtility.nearestControl == collider.GetInstanceID(); + var isHover = HandleUtility.nearestControl == collider.GetControlId(); return (IsLeftDown() && isHover, isHover); } @@ -280,7 +286,7 @@ namespace UniVRM10 { // 先頭 Handles.color = color; - Handles.CubeHandleCap(joint.GetInstanceID(), joint.transform.position, joint.transform.rotation, + Handles.CubeHandleCap(joint.GetControlId(), joint.transform.position, joint.transform.rotation, // head の radius joint.m_jointRadius, Event.current.type); } @@ -291,13 +297,13 @@ namespace UniVRM10 Handles.DrawLine(joint.transform.position, head.transform.position); // joint Handles.color = color; - Handles.SphereHandleCap(joint.GetInstanceID(), joint.transform.position, joint.transform.rotation, + Handles.SphereHandleCap(joint.GetControlId(), joint.transform.position, joint.transform.rotation, // head の radius head.m_jointRadius * 2, Event.current.type); } } - var isHover = HandleUtility.nearestControl == joint.GetInstanceID(); + var isHover = HandleUtility.nearestControl == joint.GetControlId(); return (IsLeftDown() && isHover, isHover); } } diff --git a/Packages/VRM10/Editor/Vrm10EditorUtility.cs b/Packages/VRM10/Editor/Vrm10EditorUtility.cs index 4df9bfba3..1b7eb3e3d 100644 --- a/Packages/VRM10/Editor/Vrm10EditorUtility.cs +++ b/Packages/VRM10/Editor/Vrm10EditorUtility.cs @@ -51,5 +51,18 @@ namespace UniVRM10 EditorGUI.EndProperty(); } + + /// + /// Control ID を取得 + /// + /// 対象となるコンポーネント + /// コンポーネントの Control ID + /// Control ID とは、Handles.CubeHandleCap()の第一引数等で使用可能な、コンポーネント単位でユニークなint値のこと + internal static int GetControlId(this Component component) +#if UNITY_6000_5_OR_NEWER + => component.GetEntityId().GetHashCode(); +#else + => component.GetInstanceID(); +#endif } } \ No newline at end of file diff --git a/Packages/VRM10/Runtime/Components/Expression/MorphTargetBindingMerger/MorphTargetIdentifier.cs b/Packages/VRM10/Runtime/Components/Expression/MorphTargetBindingMerger/MorphTargetIdentifier.cs index 4285d4cd7..febc4b8e0 100644 --- a/Packages/VRM10/Runtime/Components/Expression/MorphTargetBindingMerger/MorphTargetIdentifier.cs +++ b/Packages/VRM10/Runtime/Components/Expression/MorphTargetBindingMerger/MorphTargetIdentifier.cs @@ -23,19 +23,31 @@ namespace UniVRM10 } public SkinnedMeshRenderer TargetRenderer { get; } +#if UNITY_6000_5_OR_NEWER + public EntityId TargetRendererEntityId { get; } +#else public int TargetRendererInstanceId { get; } +#endif public int TargetBlendShapeIndex { get; } public MorphTargetIdentifier(SkinnedMeshRenderer targetRenderer, int targetBlendShapeIndex) { TargetRenderer = targetRenderer; +#if UNITY_6000_5_OR_NEWER + TargetRendererEntityId = targetRenderer.GetEntityId(); +#else TargetRendererInstanceId = targetRenderer.GetInstanceID(); +#endif TargetBlendShapeIndex = targetBlendShapeIndex; } public bool Equals(MorphTargetIdentifier other) { +#if UNITY_6000_5_OR_NEWER + return TargetRendererEntityId == other.TargetRendererEntityId && TargetBlendShapeIndex == other.TargetBlendShapeIndex; +#else return TargetRendererInstanceId == other.TargetRendererInstanceId && TargetBlendShapeIndex == other.TargetBlendShapeIndex; +#endif } public override bool Equals(object obj) @@ -45,7 +57,11 @@ namespace UniVRM10 public override int GetHashCode() { +#if UNITY_6000_5_OR_NEWER + return HashCode.Combine(TargetRendererEntityId, TargetBlendShapeIndex); +#else return HashCode.Combine(TargetRendererInstanceId, TargetBlendShapeIndex); +#endif } #region IEqualityComparer @@ -55,12 +71,20 @@ namespace UniVRM10 { public bool Equals(MorphTargetIdentifier x, MorphTargetIdentifier y) { +#if UNITY_6000_5_OR_NEWER + return x.TargetRendererEntityId == y.TargetRendererEntityId && x.TargetBlendShapeIndex == y.TargetBlendShapeIndex; +#else return x.TargetRendererInstanceId == y.TargetRendererInstanceId && x.TargetBlendShapeIndex == y.TargetBlendShapeIndex; +#endif } public int GetHashCode(MorphTargetIdentifier obj) { +#if UNITY_6000_5_OR_NEWER + return HashCode.Combine(obj.TargetRendererEntityId, obj.TargetBlendShapeIndex); +#else return HashCode.Combine(obj.TargetRendererInstanceId, obj.TargetBlendShapeIndex); +#endif } } #endregion diff --git a/Packages/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneCollider.cs b/Packages/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneCollider.cs index cda3d5451..a59975def 100644 --- a/Packages/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneCollider.cs +++ b/Packages/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneCollider.cs @@ -30,9 +30,15 @@ namespace UniVRM10 public Vector3 TailOrNormal => ColliderType == VRM10SpringBoneColliderTypes.Plane ? Normal : Tail; +#if UNITY_6000_5_OR_NEWER + public static EntityId SelectedEntityId; + + public bool IsSelected => GetEntityId() == SelectedEntityId; +#else public static int SelectedGuid; public bool IsSelected => GetInstanceID() == SelectedGuid; +#endif public static bool ColliderGroupsWindowActive;