mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-10 21:09:08 -05:00
VRM10ObjectLookAtEditor
This commit is contained in:
@@ -22,7 +22,7 @@ namespace UniVRM10
|
||||
// for SerializedProperty
|
||||
SerializedPropertyEditor m_expression;
|
||||
SerializedPropertyEditor m_meta;
|
||||
SerializedPropertyEditor m_lookAt;
|
||||
VRM10ObjectLookAtEditor m_lookAt;
|
||||
SerializedPropertyEditor m_firstPerson;
|
||||
SerializedProperty m_prefab;
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace UniVRM10
|
||||
|
||||
m_expression = SerializedPropertyEditor.Create(serializedObject, nameof(m_target.Expression));
|
||||
m_meta = VRM10MetaEditor.Create(serializedObject);
|
||||
m_lookAt = SerializedPropertyEditor.Create(serializedObject, nameof(m_target.LookAt));
|
||||
m_lookAt = new(serializedObject);
|
||||
m_firstPerson = SerializedPropertyEditor.Create(serializedObject, nameof(m_target.FirstPerson));
|
||||
|
||||
m_prefab = serializedObject.FindProperty("m_prefab");
|
||||
|
||||
89
Assets/VRM10/Editor/Components/VRM10ObjectLookAtEditor.cs
Normal file
89
Assets/VRM10/Editor/Components/VRM10ObjectLookAtEditor.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using UniGLTF.Extensions.VRMC_vrm;
|
||||
using UnityEditor;
|
||||
|
||||
namespace UniVRM10
|
||||
{
|
||||
public class VRM10ObjectLookAtEditor
|
||||
{
|
||||
private readonly SerializedObject _serializedObject;
|
||||
private readonly SerializedProperty _OffsetFromHead;
|
||||
private readonly SerializedProperty _LookAtType;
|
||||
|
||||
|
||||
class CurveMapEditor
|
||||
{
|
||||
private readonly SerializedProperty _CurveXRangeDegree;
|
||||
private readonly SerializedProperty _CurveYRangeDegree;
|
||||
private readonly string _name;
|
||||
|
||||
public CurveMapEditor(SerializedObject serializedObject, string name)
|
||||
{
|
||||
_CurveXRangeDegree = serializedObject.FindProperty($"LookAt.{name}.CurveXRangeDegree");
|
||||
_CurveYRangeDegree = serializedObject.FindProperty($"LookAt.{name}.CurveYRangeDegree");
|
||||
_name = name;
|
||||
}
|
||||
|
||||
public void OnInspectorGUI(float yMax)
|
||||
{
|
||||
EditorGUILayout.LabelField(_name);
|
||||
EditorGUI.indentLevel++;
|
||||
// EditorGUILayout.PropertyField(_CurveXRangeDegree);
|
||||
_CurveXRangeDegree.floatValue = EditorGUILayout.Slider("CurveXRangeDegree", _CurveXRangeDegree.floatValue, 0, 90.0f);
|
||||
// EditorGUILayout.PropertyField(_CurveYRangeDegree);
|
||||
_CurveYRangeDegree.floatValue = EditorGUILayout.Slider("CurveYRangeDegree", _CurveYRangeDegree.floatValue, 0, yMax);
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
}
|
||||
private readonly CurveMapEditor _HorizontalOuter;
|
||||
private readonly CurveMapEditor _HorizontalInner;
|
||||
private readonly CurveMapEditor _VerticalDown;
|
||||
private readonly CurveMapEditor _VerticalUp;
|
||||
|
||||
public VRM10ObjectLookAtEditor(SerializedObject serializedObject)
|
||||
{
|
||||
_serializedObject = serializedObject;
|
||||
_OffsetFromHead = serializedObject.FindProperty("LookAt.OffsetFromHead");
|
||||
_LookAtType = serializedObject.FindProperty("LookAt.LookAtType");
|
||||
_HorizontalOuter = new(serializedObject, "HorizontalOuter");
|
||||
_HorizontalInner = new(serializedObject, "HorizontalInner");
|
||||
_VerticalDown = new(serializedObject, "VerticalDown");
|
||||
_VerticalUp = new(serializedObject, "VerticalUp");
|
||||
}
|
||||
|
||||
public void OnInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.PropertyField(_OffsetFromHead);
|
||||
EditorGUILayout.PropertyField(_LookAtType);
|
||||
EditorGUILayout.Space();
|
||||
|
||||
switch ((LookAtType)_LookAtType.enumValueIndex)
|
||||
{
|
||||
case LookAtType.bone:
|
||||
{
|
||||
EditorGUILayout.HelpBox("Degree Input (0-90) => EyeBone Degree(0-90)", MessageType.Info);
|
||||
_HorizontalOuter.OnInspectorGUI(90);
|
||||
_HorizontalInner.OnInspectorGUI(90);
|
||||
_VerticalDown.OnInspectorGUI(90);
|
||||
_VerticalUp.OnInspectorGUI(90);
|
||||
}
|
||||
break;
|
||||
|
||||
case LookAtType.expression:
|
||||
{
|
||||
EditorGUILayout.HelpBox("Degree Input (0-90) => Expression Weight(0-1.0)", MessageType.Info);
|
||||
_HorizontalOuter.OnInspectorGUI(1);
|
||||
_HorizontalInner.OnInspectorGUI(1);
|
||||
_VerticalDown.OnInspectorGUI(1);
|
||||
_VerticalUp.OnInspectorGUI(1);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
_serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d31d0e4c86e078746b74b86dc473e15a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user