diff --git a/Assets/VRM10/Editor/Components/Constraint/IVRM10ConstraintSourceDestinationExtensions.cs b/Assets/VRM10/Editor/Components/Constraint/IVRM10ConstraintSourceDestinationExtensions.cs
new file mode 100644
index 000000000..38e3c6a0b
--- /dev/null
+++ b/Assets/VRM10/Editor/Components/Constraint/IVRM10ConstraintSourceDestinationExtensions.cs
@@ -0,0 +1,59 @@
+using UnityEditor;
+using UnityEngine;
+
+namespace UniVRM10
+{
+ public static class IVRM10ConstraintSourceDestinationExtensions
+ {
+ public static void DrawSourceCoords(this IVRM10ConstraintSourceDestination self)
+ {
+ try
+ {
+ self.GetSourceCoords().Draw(0.2f);
+ }
+ catch (ConstraintException)
+ {
+
+ }
+ }
+ public static void DrawSourceCurrent(this IVRM10ConstraintSourceDestination self)
+ {
+ try
+ {
+ Handles.matrix = self.GetSourceCurrent().TRS(0.05f);
+ Handles.color = Color.yellow;
+ Handles.DrawWireCube(Vector3.zero, Vector3.one);
+ }
+ catch (ConstraintException)
+ {
+
+ }
+ }
+
+ public static void DrawDstCoords(this IVRM10ConstraintSourceDestination self)
+ {
+ try
+ {
+ self.GetDstCoords().Draw(0.2f);
+ }
+ catch (ConstraintException)
+ {
+
+ }
+ }
+
+ public static void DrawDstCurrent(this IVRM10ConstraintSourceDestination self)
+ {
+ try
+ {
+ Handles.matrix = self.GetDstCurrent().TRS(0.05f);
+ Handles.color = Color.yellow;
+ Handles.DrawWireCube(Vector3.zero, Vector3.one);
+ }
+ catch (ConstraintException)
+ {
+
+ }
+ }
+ }
+}
diff --git a/Assets/VRM10/Editor/Components/Constraint/IVRM10ConstraintSourceDestinationExtensions.cs.meta b/Assets/VRM10/Editor/Components/Constraint/IVRM10ConstraintSourceDestinationExtensions.cs.meta
new file mode 100644
index 000000000..a2836e116
--- /dev/null
+++ b/Assets/VRM10/Editor/Components/Constraint/IVRM10ConstraintSourceDestinationExtensions.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 59e1ae1f9d4fb9a459cd2c97a4351b1f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/VRM10/Editor/Components/Constraint/VRM10RotationConstraintEditor.cs b/Assets/VRM10/Editor/Components/Constraint/VRM10RotationConstraintEditor.cs
index 317ceddda..c0503738c 100644
--- a/Assets/VRM10/Editor/Components/Constraint/VRM10RotationConstraintEditor.cs
+++ b/Assets/VRM10/Editor/Components/Constraint/VRM10RotationConstraintEditor.cs
@@ -1,4 +1,3 @@
-using System;
using System.Text;
using UnityEditor;
using UnityEngine;
@@ -15,39 +14,18 @@ namespace UniVRM10
m_target = (VRM10RotationConstraint)target;
}
- #region SRC
- void DrawSourceCurrent()
- {
- var s = m_target.transform.lossyScale.x;
- Handles.matrix = m_target.GetSourceCurrent().TRS(0.05f * s);
- Handles.color = Color.yellow;
- Handles.DrawWireCube(Vector3.zero, Vector3.one);
- }
-
- void DrawSourceCoords()
- {
- var s = m_target.transform.lossyScale.x;
- m_target.GetSourceCoords().Draw(0.2f / s);
- }
- #endregion
-
- #region Dst
- void DrawDstCurrent()
- {
- var s = m_target.transform.lossyScale.x;
- Handles.matrix = m_target.GetDstCurrent().TRS(0.05f * s);
- Handles.color = Color.yellow;
- Handles.DrawWireCube(Vector3.zero, Vector3.one);
- }
-
- void DrawDstCoords()
- {
- var s = m_target.transform.lossyScale.x;
- m_target.GetDstCoords().Draw(0.2f / s);
- }
- #endregion
-
static GUIStyle s_style;
+ static GUIStyle Style
+ {
+ get
+ {
+ if (s_style == null)
+ {
+ s_style = new GUIStyle("box");
+ }
+ return s_style;
+ }
+ }
///
/// Euler各を +- 180 にクランプする
@@ -74,16 +52,12 @@ namespace UniVRM10
{
return;
}
- if (s_style == null)
- {
- s_style = new GUIStyle("box");
- }
// this to target line
Handles.color = Color.yellow;
Handles.DrawLine(m_target.Source.position, m_target.transform.position);
- var euler = Clamp180(m_target.Delta.eulerAngles);
+ var delta = Clamp180(m_target.Delta.eulerAngles);
// show source
{
@@ -91,26 +65,26 @@ namespace UniVRM10
sb.AppendLine();
sb.AppendLine();
sb.AppendLine($"source: {m_target.SourceCoordinate}");
- sb.AppendLine($"{euler.x:0.}");
- sb.AppendLine($"{euler.y:0.}");
- sb.Append($"{euler.z:0.}");
- Handles.Label(m_target.Source.position, sb.ToString(), s_style);
+ sb.AppendLine($"{delta.x:0.}");
+ sb.AppendLine($"{delta.y:0.}");
+ sb.Append($"{delta.z:0.}");
+ Handles.Label(m_target.Source.position, sb.ToString(), Style);
}
// show dst
{
var sb = new StringBuilder();
sb.AppendLine($"constraint: {m_target.DestinationCoordinate}");
- sb.AppendLine(m_target.FreezeAxes.HasFlag(AxisMask.X) ? $"freeze" : $"{euler.x:0.}");
- sb.AppendLine(m_target.FreezeAxes.HasFlag(AxisMask.Y) ? $"freeze" : $"{euler.y:0.}");
- sb.Append(m_target.FreezeAxes.HasFlag(AxisMask.Z) ? $"freeze" : $"{euler.z:0.}");
- Handles.Label(m_target.transform.position, sb.ToString(), s_style);
+ sb.AppendLine(m_target.FreezeAxes.HasFlag(AxisMask.X) ? $"freeze" : $"{delta.x:0.}");
+ sb.AppendLine(m_target.FreezeAxes.HasFlag(AxisMask.Y) ? $"freeze" : $"{delta.y:0.}");
+ sb.Append(m_target.FreezeAxes.HasFlag(AxisMask.Z) ? $"freeze" : $"{delta.z:0.}");
+ Handles.Label(m_target.transform.position, sb.ToString(), Style);
}
- DrawSourceCoords();
- DrawSourceCurrent();
- DrawDstCoords();
- DrawDstCurrent();
+ m_target.DrawSourceCoords();
+ m_target.DrawSourceCurrent();
+ m_target.DrawDstCoords();
+ m_target.DrawDstCurrent();
}
}
}
diff --git a/Assets/VRM10/Runtime/Components/Constraint/IVRM10SourceDestination.cs b/Assets/VRM10/Runtime/Components/Constraint/IVRM10SourceDestination.cs
new file mode 100644
index 000000000..d6aa2ca89
--- /dev/null
+++ b/Assets/VRM10/Runtime/Components/Constraint/IVRM10SourceDestination.cs
@@ -0,0 +1,11 @@
+namespace UniVRM10
+{
+ public interface IVRM10ConstraintSourceDestination
+ {
+ TR GetSourceCoords();
+ TR GetSourceCurrent();
+
+ TR GetDstCoords();
+ TR GetDstCurrent();
+ }
+}
diff --git a/Assets/VRM10/Runtime/Components/Constraint/IVRM10SourceDestination.cs.meta b/Assets/VRM10/Runtime/Components/Constraint/IVRM10SourceDestination.cs.meta
new file mode 100644
index 000000000..ff49caec8
--- /dev/null
+++ b/Assets/VRM10/Runtime/Components/Constraint/IVRM10SourceDestination.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 4d1ea0f0f4d95a2499f9aa5a1d7a2235
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs
index 24c80d31d..635ff3782 100644
--- a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs
+++ b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs
@@ -9,7 +9,7 @@ namespace UniVRM10
/// 対象の初期回転と現在回転の差分(delta)を、自身の初期回転と自身の初期回転にdeltaを乗算したものに対してWeightでSlerpする。
///
[DisallowMultipleComponent]
- public class VRM10RotationConstraint : VRM10Constraint
+ public class VRM10RotationConstraint : VRM10Constraint, IVRM10ConstraintSourceDestination
{
[SerializeField]
public Transform Source = default;
@@ -36,10 +36,6 @@ namespace UniVRM10
ConstraintSource m_src;
- ///
- /// Source の座標系
- ///
- ///
public TR GetSourceCoords()
{
switch (SourceCoordinate)