Merge branch 'master' into fix/update_springbone_ui

This commit is contained in:
ousttrue
2026-06-26 15:41:29 +09:00
committed by GitHub
7 changed files with 89 additions and 11 deletions

View File

@@ -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
}
}

View File

@@ -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<int>;
using TreeViewItem = UnityEditor.IMGUI.Controls.TreeViewItem<int>;
using TreeViewState = UnityEditor.IMGUI.Controls.TreeViewState<int>;
#endif
namespace UniHumanoid
{
@@ -183,7 +188,7 @@ namespace UniHumanoid
}
// inside class BoneTreeView : TreeView<int>
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);

View File

@@ -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);
}

View File

@@ -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<int>;
using TreeViewItem = UnityEditor.IMGUI.Controls.TreeViewItem<int>;
using TreeViewState = UnityEditor.IMGUI.Controls.TreeViewState<int>;
#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);
}
}

View File

@@ -51,5 +51,18 @@ namespace UniVRM10
EditorGUI.EndProperty();
}
/// <summary>
/// Control ID を取得
/// </summary>
/// <param name="component">対象となるコンポーネント</param>
/// <returns>コンポーネントの Control ID</returns>
/// <remarks>Control ID とは、Handles.CubeHandleCap()の第一引数等で使用可能な、コンポーネント単位でユニークなint値のこと</remarks>
internal static int GetControlId(this Component component)
#if UNITY_6000_5_OR_NEWER
=> component.GetEntityId().GetHashCode();
#else
=> component.GetInstanceID();
#endif
}
}

View File

@@ -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

View File

@@ -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;