コード例 #1
0
        protected override void OnEnable()
        {
            m_target = (BlendShapeClip)target;

            base.OnEnable();
        }
コード例 #2
0
 public SerializedBlendShapeEditor(BlendShapeClip blendShapeClip,
                                   PreviewSceneManager previewSceneManager) : this(
         new SerializedObject(blendShapeClip), blendShapeClip, previewSceneManager)
 {
 }
コード例 #3
0
 public bool Match(BlendShapeClip clip)
 {
     return(this.Equals(CreateFromClip(clip)));
 }
コード例 #4
0
 public static BlendShapeKey CreateFrom(BlendShapeClip clip)
 {
     return(new BlendShapeKey(clip.BlendShapeName, clip.Preset));
 }
コード例 #5
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            // buttons
            if (m_target.Clips != null)
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Select BlendShapeClip", EditorStyles.boldLabel);
                var preset = GUILayout.SelectionGrid(m_preset, m_target.Clips
                                                     .Where(x => x != null)
                                                     .Select(x => BlendShapeKey.CreateFrom(x).ToString()).ToArray(), 4);
                if (preset != m_preset)
                {
                    CurrentClip = m_target.Clips[preset];
                    m_preset    = preset;
                }
            }

            // Add
            if (GUILayout.Button("Add BlendShapeClip"))
            {
                AddBlendShapeClip();
            }

            if (CurrentClip != null)
            {
                // clip
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("CurrentClip", EditorStyles.boldLabel);

                /*var loadClip = (BlendShapeClip)*/
                GUI.enabled = false;
                EditorGUILayout.ObjectField("Current clip",
                                            CurrentClip, typeof(BlendShapeClip), false);
                GUI.enabled = true;

                CurrentClip.Preset = (BlendShapePreset)EditorGUILayout.Popup("Preset", (int)CurrentClip.Preset, Presets);

                CurrentClip.BlendShapeName = EditorGUILayout.TextField("BlendShapeName", CurrentClip.BlendShapeName);

                var key = BlendShapeKey.CreateFrom(CurrentClip);
                if (m_target.Clips.Where(x => key.Match(x)).Count() > 1)
                {
                    EditorGUILayout.HelpBox("duplicate clip", MessageType.Error);
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("BlendShapeValues", EditorStyles.boldLabel);

                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Clear"))
                {
                    ClearBlendShape();
                }

                if (CurrentClip != null && GUILayout.Button("Apply"))
                {
                    string maxWeightString;
                    CurrentClip.Values = GetBindings(out maxWeightString);
                }
                EditorGUILayout.EndHorizontal();

                // sliders
                bool changed   = false;
                int  foldIndex = 0;
                foreach (var item in PreviewSceneManager.EnumRenderItems.Where(x => x.SkinnedMeshRenderer != null))
                {
                    var mesh = item.SkinnedMeshRenderer.sharedMesh;
                    if (mesh != null && mesh.blendShapeCount > 0)
                    {
                        //var relativePath = UniGLTF.UnityExtensions.RelativePathFrom(renderer.transform, m_target.transform);
                        //EditorGUILayout.LabelField(m_target.name + "/" + item.Path);

                        if (foldIndex >= m_meshFolds.Count)
                        {
                            m_meshFolds.Add(false);
                        }
                        m_meshFolds[foldIndex] = EditorGUILayout.Foldout(m_meshFolds[foldIndex], item.SkinnedMeshRenderer.name);
                        if (m_meshFolds[foldIndex])
                        {
                            //EditorGUI.indentLevel += 1;
                            for (int i = 0; i < mesh.blendShapeCount; ++i)
                            {
                                var src = item.SkinnedMeshRenderer.GetBlendShapeWeight(i);
                                var dst = EditorGUILayout.Slider(mesh.GetBlendShapeName(i), src, 0, 100.0f);
                                if (dst != src)
                                {
                                    item.SkinnedMeshRenderer.SetBlendShapeWeight(i, dst);
                                    changed = true;
                                }
                            }
                            //EditorGUI.indentLevel -= 1;
                        }
                        ++foldIndex;
                    }
                }

                if (changed)
                {
                    PreviewSceneManager.Bake();
                }
            }
        }
コード例 #6
0
 public static void Add(this glTF_VRM_BlendShapeMaster master,
                        BlendShapeClip clip, gltfExporter exporter)
 {
     master.blendShapeGroups.Add(clip.Serialize(exporter));
 }