mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-27 21:34:38 -05:00
Vrm10RuntimeExpression.Dispose. offset,scale
This commit is contained in:
@@ -28,6 +28,7 @@ namespace UniVRM10
|
||||
static bool s_foldRuntimeLookAt = false;
|
||||
|
||||
Vrm10Instance m_instance;
|
||||
private Dictionary<string, Material> m_materials = new();
|
||||
|
||||
SerializedProperty m_script;
|
||||
SerializedProperty m_vrmObject;
|
||||
@@ -42,6 +43,14 @@ namespace UniVRM10
|
||||
void OnEnable()
|
||||
{
|
||||
m_instance = (Vrm10Instance)target;
|
||||
m_materials.Clear();
|
||||
foreach (var r in m_instance.GetComponentsInChildren<Renderer>())
|
||||
{
|
||||
foreach (var m in r.sharedMaterials)
|
||||
{
|
||||
m_materials.TryAdd(m.name, m);
|
||||
}
|
||||
}
|
||||
m_script = serializedObject.FindProperty("m_Script");
|
||||
|
||||
m_vrmObject = serializedObject.FindProperty(nameof(m_instance.Vrm));
|
||||
@@ -277,6 +286,33 @@ namespace UniVRM10
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
void showuv(ExpressionPreset preset)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
try
|
||||
{
|
||||
var (_, clip) = m_instance.Vrm.Expression.Clips.FirstOrDefault(x => x.Preset == preset);
|
||||
if (clip != null)
|
||||
{
|
||||
foreach (var b in clip.MaterialUVBindings)
|
||||
{
|
||||
if (m_materials.TryGetValue(b.MaterialName, out var m))
|
||||
{
|
||||
EditorGUILayout.TextField(b.MaterialName, $"{b.Offset},${b.Scaling} => {m.mainTextureOffset},{m.mainTextureScale}");
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.TextField(b.MaterialName, "not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
|
||||
void GUILookAt()
|
||||
{
|
||||
if (!target)
|
||||
@@ -312,6 +348,7 @@ namespace UniVRM10
|
||||
if (w.TryGetValue(ExpressionKey.LookLeft, out var left))
|
||||
{
|
||||
EditorGUILayout.Slider("left", left, 0, 1);
|
||||
showuv(ExpressionPreset.lookLeft);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -321,6 +358,7 @@ namespace UniVRM10
|
||||
if (w.TryGetValue(ExpressionKey.LookRight, out var right))
|
||||
{
|
||||
EditorGUILayout.Slider("right", right, 0, 1);
|
||||
showuv(ExpressionPreset.lookRight);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -330,6 +368,7 @@ namespace UniVRM10
|
||||
if (w.TryGetValue(ExpressionKey.LookUp, out var up))
|
||||
{
|
||||
EditorGUILayout.Slider("up", up, 0, 1);
|
||||
showuv(ExpressionPreset.lookUp);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -339,11 +378,14 @@ namespace UniVRM10
|
||||
if (w.TryGetValue(ExpressionKey.LookDown, out var down))
|
||||
{
|
||||
EditorGUILayout.Slider("down", down, 0, 1);
|
||||
showuv(ExpressionPreset.lookDown);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.TextField("down");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace UniVRM10
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Expression.Dispose();
|
||||
ControlRig?.Dispose();
|
||||
SpringBone.Dispose();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace UniVRM10
|
||||
{
|
||||
public sealed class Vrm10RuntimeExpression
|
||||
public sealed class Vrm10RuntimeExpression : IDisposable
|
||||
{
|
||||
public static IExpressionValidatorFactory ExpressionValidatorFactory = new DefaultExpressionValidator.Factory();
|
||||
|
||||
@@ -22,12 +23,8 @@ namespace UniVRM10
|
||||
public float LookAtOverrideRate { get; private set; }
|
||||
public float MouthOverrideRate { get; private set; }
|
||||
|
||||
int m_debugCount;
|
||||
|
||||
internal Vrm10RuntimeExpression(Vrm10Instance target, ILookAtEyeDirectionApplicable eyeDirectionApplicable)
|
||||
{
|
||||
Restore();
|
||||
|
||||
_merger = new ExpressionMerger(target.Vrm.Expression, target.transform);
|
||||
_keys = target.Vrm.Expression.Clips
|
||||
.Select(x => target.Vrm.Expression.CreateKey(x.Clip))
|
||||
@@ -52,7 +49,7 @@ namespace UniVRM10
|
||||
_eyeDirectionApplicable = eyeDirectionApplicable;
|
||||
}
|
||||
|
||||
internal void Restore()
|
||||
public void Dispose()
|
||||
{
|
||||
_merger?.RestoreMaterialInitialValues();
|
||||
_merger = null;
|
||||
|
||||
Reference in New Issue
Block a user