From 4d2c769f0be2f6be16b4ce8c7fa53d93216ef499 Mon Sep 17 00:00:00 2001 From: matsutaka Date: Wed, 24 Jun 2026 17:17:40 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20VRM10=20-=20Unity=206.5=20=E3=81=A7?= =?UTF-8?q?=E3=81=AE=E3=82=A8=E3=83=A9=E3=83=BC=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - TreeViewをTreeViewに変更 - GetInstanceID()をGetEntityId()に置き換え - 上記の受け型もintからEntityIdに変更 - Handles.SphereHandleCap()等の第一引数 control id をコンポーネントから取得する関数を追加 --- .../Components/SpringBone/SelectedGUI.cs | 14 ++++++++++ .../SpringBone/SpringBoneTreeView.cs | 26 +++++++++++++------ .../MorphTargetIdentifier.cs | 24 +++++++++++++++++ .../SpringBone/VRM10SpringBoneCollider.cs | 6 +++++ 4 files changed, 62 insertions(+), 8 deletions(-) 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..36ad8e644 100644 --- a/Packages/VRM10/Editor/Components/SpringBone/SpringBoneTreeView.cs +++ b/Packages/VRM10/Editor/Components/SpringBone/SpringBoneTreeView.cs @@ -1,7 +1,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 UniVRM10 { @@ -254,20 +258,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(GetControlId(collider), 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(GetControlId(collider), collider.Offset, Quaternion.identity, collider.Radius * 2, Event.current.type); + Handles.SphereHandleCap(GetControlId(collider), 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 == GetControlId(collider); return (IsLeftDown() && isHover, isHover); } @@ -280,7 +284,7 @@ namespace UniVRM10 { // 先頭 Handles.color = color; - Handles.CubeHandleCap(joint.GetInstanceID(), joint.transform.position, joint.transform.rotation, + Handles.CubeHandleCap(GetControlId(joint), joint.transform.position, joint.transform.rotation, // head の radius joint.m_jointRadius, Event.current.type); } @@ -291,14 +295,20 @@ 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(GetControlId(joint), 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 == GetControlId(joint); return (IsLeftDown() && isHover, isHover); } + +#if UNITY_6000_5_OR_NEWER + static int GetControlId(Component component) => EntityId.ToULong(component.GetEntityId()).GetHashCode(); +#else + static int GetControlId(Component component) => component.GetInstanceID(); +#endif } } 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 0685eb687..fa0705879 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 void OnValidate() {