mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-27 13:23:44 -05:00
fix: VRM10 - Unity 6.5 でのエラーを修正
- TreeViewをTreeView<T>に変更 - GetInstanceID()をGetEntityId()に置き換え - 上記の受け型もintからEntityIdに変更 - Handles.SphereHandleCap()等の第一引数 control id をコンポーネントから取得する関数を追加
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<int>;
|
||||
using TreeViewItem = UnityEditor.IMGUI.Controls.TreeViewItem<int>;
|
||||
using TreeViewState = UnityEditor.IMGUI.Controls.TreeViewState<int>;
|
||||
#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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user