mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-07 19:38:13 -05:00
BlendShapeProxyのEditorモード廃止とMaterialMorph対応
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
class BlendShapeSlider
|
||||
{
|
||||
VRMBlendShapeProxy m_target;
|
||||
BlendShapeKey m_key;
|
||||
float? m_editorValue;
|
||||
|
||||
public BlendShapeSlider(VRMBlendShapeProxy target, BlendShapeKey key)
|
||||
{
|
||||
m_target = target;
|
||||
m_key = key;
|
||||
}
|
||||
|
||||
public void Slider()
|
||||
{
|
||||
if (m_target.BlendShapeAvatar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
var oldValue = m_target.GetValue(m_key);
|
||||
var newValue = EditorGUILayout.Slider(m_key.ToString(), oldValue, 0, 1.0f);
|
||||
if (oldValue != newValue)
|
||||
{
|
||||
m_target.SetValue(m_key, newValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var oldValue = m_editorValue.HasValue ? m_editorValue.Value : 0.0f;
|
||||
var newValue = EditorGUILayout.Slider(m_key.ToString(), oldValue, 0, 1.0f);
|
||||
if (oldValue != newValue)
|
||||
{
|
||||
var clip = m_target.BlendShapeAvatar.GetClip(m_key);
|
||||
if (clip != null)
|
||||
{
|
||||
clip.Apply(m_target.transform, newValue);
|
||||
m_editorValue = newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RestoreEditorValue()
|
||||
{
|
||||
if (m_editorValue.HasValue)
|
||||
{
|
||||
var clip = m_target.BlendShapeAvatar.GetClip(m_key);
|
||||
if (clip != null)
|
||||
{
|
||||
clip.Apply(m_target.transform, m_editorValue.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84dd38a83c8fb594484159a563312a26
|
||||
timeCreated: 1520579905
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -11,29 +9,19 @@ namespace VRM
|
||||
{
|
||||
VRMBlendShapeProxy m_target;
|
||||
SkinnedMeshRenderer[] m_renderers;
|
||||
List<BlendShapeSlider> m_sliders;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
m_target = (VRMBlendShapeProxy)target;
|
||||
|
||||
if (m_target.BlendShapeAvatar != null)
|
||||
{
|
||||
m_sliders = m_target.BlendShapeAvatar.Clips
|
||||
.Where(x => x != null)
|
||||
.Select(x => new BlendShapeSlider(m_target, BlendShapeKey.CreateFrom(x)))
|
||||
.ToList()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
if (m_sliders != null)
|
||||
if (m_target.Sliders != null)
|
||||
{
|
||||
foreach (var slider in m_sliders)
|
||||
foreach (var slider in m_target.Sliders)
|
||||
{
|
||||
slider.Slider();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user