Beispiel #1
0
 void OnSelected(BlendShapeClip clip)
 {
     if (PreviewSceneManager == null)
     {
         m_clipEditor = null;
     }
     else if (clip != null)
     {
         m_clipEditor = new SerializedBlendShapeEditor(clip, PreviewSceneManager);
         PreviewSceneManager.Bake(new PreviewSceneManager.BakeValue
         {
             BlendShapeBindings    = clip.Values,
             MaterialValueBindings = clip.MaterialValues,
             Weight = 1.0f
         });
     }
     else
     {
         m_clipEditor = null;
         PreviewSceneManager.Bake(new PreviewSceneManager.BakeValue());
     }
 }
Beispiel #2
0
        public override void OnInspectorGUI()
        {
            if (PreviewSceneManager == null)
            {
                return;
            }
            serializedObject.Update();

            if (m_serializedEditor == null)
            {
                m_serializedEditor = new SerializedBlendShapeEditor(serializedObject, PreviewSceneManager);
                //m_thumbnailProp = serializedObject.FindProperty("Thumbnail");
                m_isBinaryProp = serializedObject.FindProperty("IsBinary");
            }

            int thumbnailSize = 96;

            EditorGUILayout.BeginHorizontal();

            /*
             * var objectReferenceValue = EditorGUILayout.ObjectField(m_thumbnailProp.objectReferenceValue, typeof(Texture), false,
             *  GUILayout.Width(thumbnailSize), GUILayout.Height(thumbnailSize));
             * if (m_thumbnailProp.objectReferenceValue != objectReferenceValue)
             * {
             *  m_thumbnailProp.objectReferenceValue = objectReferenceValue;
             *  serializedObject.ApplyModifiedProperties();
             * }
             */

            var changed = false;

            EditorGUILayout.BeginVertical();
            base.OnInspectorGUI();
            EditorGUILayout.LabelField("Preview Weight");
            var previewSlider = EditorGUILayout.Slider(m_previewSlider, 0, 1.0f);

            GUI.enabled = PreviewTexture != null;

            /*
             * if (GUILayout.Button("save thumbnail"))
             * {
             *  //var ext = "jpg";
             *  var ext = "png";
             *  var asset = UnityPath.FromAsset(target);
             *  var path = EditorUtility.SaveFilePanel(
             *                 "save thumbnail",
             *                 asset.Parent.FullPath,
             *                 string.Format("{0}.{1}", asset.FileNameWithoutExtension, ext),
             *                 ext);
             *  if (!string.IsNullOrEmpty(path))
             *  {
             *      var thumbnail = SaveResizedImage(PreviewTexture, UnityPath.FromFullpath(path),
             *      BlendShapeClipDrawer.ThumbnailSize);
             *      m_thumbnailProp.objectReferenceValue = thumbnail;
             *      serializedObject.ApplyModifiedProperties();
             *  }
             * }
             */
            GUI.enabled = true;
            EditorGUILayout.EndVertical();

            if (m_isBinaryProp.boolValue)
            {
                previewSlider = Mathf.Round(previewSlider);
            }
            if (previewSlider != m_previewSlider)
            {
                m_previewSlider = previewSlider;
                changed         = true;
            }

            EditorGUILayout.EndHorizontal();
            Separator();
            EditorGUILayout.Space();

            var result = m_serializedEditor.Draw();

            if ((changed || result.Changed) && PreviewSceneManager != null)
            {
                PreviewSceneManager.Bake(new PreviewSceneManager.BakeValue
                {
                    BlendShapeBindings    = result.BlendShapeBindings,
                    MaterialValueBindings = result.MaterialValueBindings,
                    Weight = m_previewSlider
                });
            }
        }