Пример #1
0
        override public void OnInspectorGUI()
        {
            Sprite oldSprite = m_SpriteProperty.objectReferenceValue as Sprite;

            EditorGUI.BeginChangeCheck();

            serializedObject.Update();

            EditorGUILayout.PropertyField(m_SpriteProperty);

            serializedObject.ApplyModifiedProperties();

            if (EditorGUI.EndChangeCheck())
            {
                Sprite sprite = m_SpriteProperty.objectReferenceValue as Sprite;

                SpriteMeshUtils.UpdateAssets(target as SpriteMesh);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
                AssetDatabase.StartAssetEditing();

                if (oldSprite)
                {
                    AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(oldSprite));
                }

                AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(sprite));
                AssetDatabase.StopAssetEditing();
            }

            serializedObject.Update();

            EditorGUI.BeginDisabledGroup(true);

            EditorGUILayout.PropertyField(m_SharedMeshProperty);
            EditorGUILayout.PropertyField(m_SharedMaterialsProperty, true);

            EditorGUI.EndDisabledGroup();

            EditorGUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Edit Sprite Mesh", GUILayout.Width(150f)))
            {
                SpriteMeshEditorWindow window = SpriteMeshEditorWindow.GetWindow();
                window.UpdateFromSelection();
            }

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();

            serializedObject.ApplyModifiedProperties();
        }
Пример #2
0
        override public void OnInspectorGUI()
        {
            DrawDefaultInspector();

            SpriteMesh spriteMesh = target as SpriteMesh;

            EditorGUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Edit Sprite Mesh", GUILayout.Width(150f)))
            {
                SpriteMeshEditorWindow.Initialize(spriteMesh);
            }

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();
        }