From d63517babe31a9a383e0df06d02c76a00a1e3d97 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 5 Nov 2018 15:45:29 +0900 Subject: [PATCH] Fixed preview for ST_S and ST_T --- .../BlendShape/Editor/BlendShapeClipDrawer.cs | 2 +- .../Editor/BlendShapeClipEditorHelper.cs | 39 ++++++++++++++----- Scripts/BlendShape/PreviewSceneManager.cs | 13 ++++++- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/Scripts/BlendShape/Editor/BlendShapeClipDrawer.cs b/Scripts/BlendShape/Editor/BlendShapeClipDrawer.cs index a8dec2adb..822a5a09f 100644 --- a/Scripts/BlendShape/Editor/BlendShapeClipDrawer.cs +++ b/Scripts/BlendShape/Editor/BlendShapeClipDrawer.cs @@ -22,7 +22,7 @@ namespace VRM { using (new EditorGUI.PropertyScope(position, label, property)) { - EditorGUIUtility.labelWidth = 80; + //EditorGUIUtility.labelWidth = 80; position.height = EditorGUIUtility.singleLineHeight; diff --git a/Scripts/BlendShape/Editor/BlendShapeClipEditorHelper.cs b/Scripts/BlendShape/Editor/BlendShapeClipEditorHelper.cs index 9b5010968..cc7eec3dc 100644 --- a/Scripts/BlendShape/Editor/BlendShapeClipEditorHelper.cs +++ b/Scripts/BlendShape/Editor/BlendShapeClipEditorHelper.cs @@ -201,27 +201,48 @@ namespace VRM return rect; } + static float[] v2 = new float[2]; + static GUIContent[] l2 = new GUIContent[]{ + new GUIContent("x"), + new GUIContent("y") + }; static Vector4 TilingOffset(Rect rect, string label, Vector4 src) { + /* var style = new GUIStyle() { alignment = TextAnchor.MiddleRight, }; + */ - var quad = rect.width / 10; + var quad = (rect.width - 56); var x = rect.x; + //EditorGUIUtility.labelWidth = 18; - EditorGUI.LabelField(AdvanceRect(ref x, rect.y, quad * 2, rect.height), "Tiling X", style); - src.x = EditorGUI.FloatField(AdvanceRect(ref x, rect.y, quad, rect.height), src.x); + EditorGUI.LabelField(AdvanceRect(ref x, rect.y, 40, rect.height), "Tiling"); + v2[0] = src.x; + v2[1] = src.y; + EditorGUI.MultiFloatField(AdvanceRect(ref x, rect.y, quad, rect.height), l2, v2); + src.x = v2[0]; + src.y = v2[1]; - EditorGUI.LabelField(AdvanceRect(ref x, rect.y, quad, rect.height), "Y", style); - src.y = EditorGUI.FloatField(AdvanceRect(ref x, rect.y, quad, rect.height), src.y); + //EditorGUI.LabelField(AdvanceRect(ref x, rect.y, quad, rect.height), "Y", style); + //src.y = EditorGUI.FloatField(AdvanceRect(ref x, rect.y, quad, rect.height), "Y", src.y); - EditorGUI.LabelField(AdvanceRect(ref x, rect.y, quad * 2, rect.height), "Offset X", style); - src.z = EditorGUI.FloatField(AdvanceRect(ref x, rect.y, quad, rect.height), src.z); + rect.y += EditorGUIUtility.singleLineHeight; + x = rect.x; + EditorGUI.LabelField(AdvanceRect(ref x, rect.y, 40, rect.height), "Offset"); + v2[0] = src.z; + v2[1] = src.w; + EditorGUI.MultiFloatField(AdvanceRect(ref x, rect.y, quad, rect.height), l2, v2); + src.z = v2[0]; + src.w = v2[1]; - EditorGUI.LabelField(AdvanceRect(ref x, rect.y, quad, rect.height), "Y", style); - src.w = EditorGUI.FloatField(AdvanceRect(ref x, rect.y, quad, rect.height), src.w); + //EditorGUI.LabelField(AdvanceRect(ref x, rect.y, quad * 2, rect.height), "Offset X", style); + //src.z = EditorGUI.FloatField(AdvanceRect(ref x, rect.y, quad, rect.height), "X", src.z); + + //EditorGUI.LabelField(AdvanceRect(ref x, rect.y, quad, rect.height), "Y", style); + //src.w = EditorGUI.FloatField(AdvanceRect(ref x, rect.y, quad, rect.height), "Y", src.w); return src; } diff --git a/Scripts/BlendShape/PreviewSceneManager.cs b/Scripts/BlendShape/PreviewSceneManager.cs index 0bf80978f..0ed21272f 100644 --- a/Scripts/BlendShape/PreviewSceneManager.cs +++ b/Scripts/BlendShape/PreviewSceneManager.cs @@ -254,8 +254,17 @@ namespace VRM PropItem prop; if (item.PropMap.TryGetValue(x.ValueName, out prop)) { - var value = x.BaseValue + (x.TargetValue - x.BaseValue) * bake.Weight; - item.Material.SetColor(x.ValueName, value); + var valueName = x.ValueName; + if (valueName.EndsWith("_ST_S") + || valueName.EndsWith("_ST_T")) + { + valueName = valueName.Substring(0, valueName.Length - 2); + } + + var value = item.Material.GetVector(valueName); + Debug.LogFormat("{0} => {1}", valueName, x.TargetValue); + value += ((x.TargetValue - x.BaseValue) * bake.Weight); + item.Material.SetColor(valueName, value); } } }