mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-20 01:37:59 -05:00
add BlendShapeClipEditor
This commit is contained in:
parent
83dea51fac
commit
c392bd27e3
31
Scripts/BlendShape/Editor/BlendShapeBindingPropertyDrawer.cs
Normal file
31
Scripts/BlendShape/Editor/BlendShapeBindingPropertyDrawer.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(BlendShapeBinding))]
|
||||
public class BlendShapeBindingPropertyDrawer : PropertyDrawer
|
||||
{
|
||||
public static int GUIElementHeight = 60;
|
||||
|
||||
public override void OnGUI(Rect position,
|
||||
SerializedProperty property, GUIContent label)
|
||||
{
|
||||
using (new EditorGUI.PropertyScope(position, label, property))
|
||||
{
|
||||
var y = position.y;
|
||||
for (var depth = property.depth;
|
||||
property.NextVisible(true) && property.depth >= depth;
|
||||
)
|
||||
{
|
||||
{
|
||||
var height = EditorGUI.GetPropertyHeight(property);
|
||||
EditorGUI.PropertyField(new Rect(position.x, y, position.width, height), property, false);
|
||||
y += height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 128cbb6916bbc7b4f89deb96d22af39e
|
||||
timeCreated: 1522997334
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
|
|
@ -7,13 +8,47 @@ namespace VRM
|
|||
[CustomEditor(typeof(BlendShapeClip))]
|
||||
public class BlendShapeClipEditor : Editor
|
||||
{
|
||||
#region for Editor
|
||||
SerializedProperty m_BlendShapeNameProp;
|
||||
SerializedProperty m_PresetProp;
|
||||
SerializedProperty m_ValuesProp;
|
||||
ReorderableList m_ValuesList;
|
||||
SerializedProperty m_MaterialValuesProp;
|
||||
ReorderableList m_MaterialValuesList;
|
||||
#endregion
|
||||
|
||||
#region for Preview
|
||||
GameObject m_prefab;
|
||||
PreviewFaceRenderer m_renderer;
|
||||
BlendShapeClip m_target;
|
||||
#endregion
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_target = (BlendShapeClip)target;
|
||||
m_BlendShapeNameProp = serializedObject.FindProperty("BlendShapeName");
|
||||
m_PresetProp = serializedObject.FindProperty("Preset");
|
||||
m_ValuesProp = serializedObject.FindProperty("Values");
|
||||
|
||||
m_ValuesList = new ReorderableList(serializedObject, m_ValuesProp);
|
||||
m_ValuesList.elementHeight = BlendShapeBindingPropertyDrawer.GUIElementHeight;
|
||||
m_ValuesList.drawElementCallback =
|
||||
(rect, index, isActive, isFocused) => {
|
||||
var element = m_ValuesProp.GetArrayElementAtIndex(index);
|
||||
rect.height -= 4;
|
||||
rect.y += 2;
|
||||
EditorGUI.PropertyField(rect, element);
|
||||
};
|
||||
|
||||
m_MaterialValuesProp = serializedObject.FindProperty("MaterialValues");
|
||||
m_MaterialValuesList = new ReorderableList(serializedObject, m_MaterialValuesProp);
|
||||
m_MaterialValuesList.elementHeight = MaterialValueBindingPropertyDrawer.GUIElementHeight;
|
||||
m_MaterialValuesList.drawElementCallback =
|
||||
(rect, index, isActive, isFocused) => {
|
||||
var element = m_MaterialValuesProp.GetArrayElementAtIndex(index);
|
||||
rect.height -= 4;
|
||||
rect.y += 2;
|
||||
EditorGUI.PropertyField(rect, element);
|
||||
};
|
||||
|
||||
var assetPath = AssetDatabase.GetAssetPath(target);
|
||||
|
||||
//Debug.LogFormat("BlendShapeClipEditor: {0}", assetPath);
|
||||
|
|
@ -48,10 +83,25 @@ namespace VRM
|
|||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
//base.OnInspectorGUI();
|
||||
|
||||
//攻撃力の数値をラベルとして表示する
|
||||
//EditorGUILayout.LabelField("攻撃力", character.攻撃力.ToString());
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.PropertyField(m_BlendShapeNameProp, true);
|
||||
EditorGUILayout.PropertyField(m_PresetProp, true);
|
||||
|
||||
EditorGUILayout.LabelField("BlendShapeBindings", EditorStyles.boldLabel);
|
||||
//EditorGUILayout.PropertyField(m_ValuesProp, true);
|
||||
m_ValuesList.DoLayoutList();
|
||||
|
||||
EditorGUILayout.LabelField("MaterialValueBindings", EditorStyles.boldLabel);
|
||||
//EditorGUILayout.PropertyField(m_BlendShapeNameProp);
|
||||
m_MaterialValuesList.DoLayoutList();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
// very important to override this, it tells Unity to render an ObjectPreview at the bottom of the inspector
|
||||
|
|
@ -83,7 +133,7 @@ namespace VRM
|
|||
GUI.DrawTexture(r, image, ScaleMode.StretchToFill, false); // draw the RenderTexture in the ObjectPreview pane
|
||||
|
||||
EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 40f),
|
||||
BlendShapeKey.CreateFrom(m_target).ToString());
|
||||
BlendShapeKey.CreateFrom((BlendShapeClip)target).ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(MaterialValueBinding))]
|
||||
public class MaterialValueBindingPropertyDrawer : PropertyDrawer
|
||||
{
|
||||
public static int GUIElementHeight = 90;
|
||||
|
||||
public override void OnGUI(Rect position,
|
||||
SerializedProperty property, GUIContent label)
|
||||
{
|
||||
using (new EditorGUI.PropertyScope(position, label, property))
|
||||
{
|
||||
var y = position.y;
|
||||
for (var depth = property.depth;
|
||||
property.NextVisible(true) && property.depth >= depth;
|
||||
)
|
||||
{
|
||||
{
|
||||
var height = EditorGUI.GetPropertyHeight(property);
|
||||
EditorGUI.PropertyField(new Rect(position.x, y, position.width, height), property, false);
|
||||
y += height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 06e4436c683663e40abfdce36b92e11d
|
||||
timeCreated: 1522997334
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in New Issue
Block a user