diff --git a/Scripts/BlendShape/Editor/VRMBlnedShapeProxyEditor.cs b/Scripts/BlendShape/Editor/VRMBlnedShapeProxyEditor.cs index 67fc5b38f..49be8d1ab 100644 --- a/Scripts/BlendShape/Editor/VRMBlnedShapeProxyEditor.cs +++ b/Scripts/BlendShape/Editor/VRMBlnedShapeProxyEditor.cs @@ -19,7 +19,6 @@ namespace VRM if (m_target.BlendShapeAvatar != null) { - m_sliders = m_target.BlendShapeAvatar.Clips .Where(x => x != null) .Select(x => new BlendShapeSlider(m_target, BlendShapeKey.CreateFrom(x))) diff --git a/Scripts/BlendShape/PreviewSceneManager.cs b/Scripts/BlendShape/PreviewSceneManager.cs index da273fa02..5f86207b2 100644 --- a/Scripts/BlendShape/PreviewSceneManager.cs +++ b/Scripts/BlendShape/PreviewSceneManager.cs @@ -204,7 +204,7 @@ namespace VRM if (materialValues != null && m_materialMap != null) { // clear - Debug.LogFormat("clear material"); + //Debug.LogFormat("clear material"); foreach (var kv in m_materialMap) { foreach (var _kv in kv.Value.PropMap) @@ -218,7 +218,7 @@ namespace VRM MaterialItem item; if (m_materialMap.TryGetValue(x.MaterialName, out item)) { - Debug.Log("set material"); + //Debug.Log("set material"); PropItem prop; if (item.PropMap.TryGetValue(x.ValueName, out prop)) { diff --git a/Scripts/Format/VRMImporter.cs b/Scripts/Format/VRMImporter.cs index bdcebb688..549a30f34 100644 --- a/Scripts/Format/VRMImporter.cs +++ b/Scripts/Format/VRMImporter.cs @@ -318,13 +318,33 @@ namespace VRM var relativePath = UniGLTF.UnityExtensions.RelativePathFrom(node, context.Root.transform); return new BlendShapeBinding { - //Name = name, RelativePath = relativePath, Index = x.index, Weight = x.weight, }; }) .ToArray(); + asset.MaterialValues = group.materialValues.Select(x => + { + var value = new Vector4(); + for(int i=0; i - /// BlendShapeBind - /// + [Serializable] + public class glTF_VRM_MaterialValueBind : UniGLTF.JsonSerializableBase + { + public string materialName; + public string propertyName; + public float[] targetValue; + + protected override void SerializeMembers(JsonFormatter f) + { + f.KeyValue(() => materialName); + f.KeyValue(() => propertyName); + f.KeyValue(() => targetValue); + } + } + [Serializable] public class glTF_VRM_BlendShapeBind : UniGLTF.JsonSerializableBase { @@ -75,22 +87,15 @@ namespace VRM { public string name; public string presetName; - [Obsolete] - public string extendedName; public List binds = new List(); + public List materialValues = new List(); protected override void SerializeMembers(JsonFormatter f) { f.KeyValue(() => name); f.KeyValue(() => presetName); - /* - if (name == "extended") - { - f.KeyValue(() => extendedName); - } - f.Key("flags"); f.Value((int)flags); - */ f.KeyValue(() => binds); + f.KeyValue(() => materialValues); } } @@ -106,11 +111,24 @@ namespace VRM { list.AddRange(clip.Values.Select(y => glTF_VRM_BlendShapeBind.Cerate(transform, meshes.ToList(), y))); } + + var materialList = new List(); + if (clip.MaterialValues != null) + { + materialList.AddRange(clip.MaterialValues.Select(y => new glTF_VRM_MaterialValueBind + { + materialName = y.MaterialName, + propertyName = y.ValueName, + targetValue = y.TargetValue.ToArray(), + })); + } + var group = new glTF_VRM_BlendShapeGroup { name = clip.BlendShapeName, presetName = clip.Preset.ToString().ToLower(), binds = list, + materialValues = materialList, }; blendShapeGroups.Add(group); }