コード例 #1
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            base.OnInspectorGUI();

            m_mode = GUILayout.Toolbar(m_mode, MODES);
            switch (m_mode)
            {
            case 0:
                m_selector.SelectGUI();
                if (m_clipEditor != null)
                {
                    Separator();
                    var result = m_clipEditor.Draw();
                    if (result.Changed)
                    {
                        PreviewSceneManager.Bake(new PreviewSceneManager.BakeValue
                        {
                            BlendShapeBindings    = result.BlendShapeBindings,
                            MaterialValueBindings = result.MaterialValueBindings,
                            Weight = 1.0f,
                        });
                    }
                }
                break;

            case 1:
                m_clipList.DoLayoutList();
                break;

            default:
                throw new NotImplementedException();
            }

            serializedObject.ApplyModifiedProperties();
        }
コード例 #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
                });
            }
        }