Esempio n. 1
0
        private void DrawGUIPaintView()
        {
            if (meshAttributes != null)
            {
                RefreshPreviewTextureCache();
                int prevSelectedAttributeIndex = selectedAttributeIndex;
                selectedAttributeIndex =
                    SplatWeightEditor.OnInspectorGUI(selectedAttributeIndex, ref brushColor, meshAttributes);
                if (prevSelectedAttributeIndex != selectedAttributeIndex)
                {
                    SetBrushColorWithAttributeIndex(selectedAttributeIndex);
                }

#if POLYBRUSH_DEBUG
                GUILayout.BeginHorizontal();

                GUILayout.FlexibleSpace();

                if (GUILayout.Button("MetaData", EditorStyles.miniButton))
                {
                    Debug.Log(meshAttributes.ToString("\n"));

                    string str = EditorUtility.FindPolybrushMetaDataForShader(meshAttributesContainer.shader);

                    if (!string.IsNullOrEmpty(str))
                    {
                        TextAsset asset = AssetDatabase.LoadAssetAtPath <TextAsset>(str);

                        if (asset != null)
                        {
                            EditorGUIUtility.PingObject(asset);
                        }
                        else
                        {
                            Debug.LogWarning("No MetaData found for Shader \"" + meshAttributesContainer.shader.name + "\"");
                        }
                    }
                    else
                    {
                        Debug.LogWarning("No MetaData found for Shader \"" + meshAttributesContainer.shader.name + "\"");
                    }
                }

                GUILayout.EndHorizontal();

                GUILayout.Space(4);

                if (GUILayout.Button("rebuild  targets"))
                {
                    RebuildColorTargets(brushColor, brushSettings.strength);
                }


                GUILayout.Label(brushColor != null ? brushColor.ToString() : "brush color: null\n");
#endif
            }
            else
            {
                if (!m_LikelySupportsTextureBlending)
                {
                    EditorGUILayout.HelpBox("It doesn't look like any of the materials on this object support texture blending!\n\nSee the readme for information on creating custom texture blend shaders.", MessageType.Warning);
                }
            }
        }
        // Inspector GUI shown in the Editor window.  Base class shows BrushSettings by default
        internal override void DrawGUI(BrushSettings brushSettings)
        {
            base.DrawGUI(brushSettings);

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();
                paintMode = (PaintMode)GUILayout.Toolbar((int)paintMode, m_ModeIcons, GUILayout.Width(130));
                GUILayout.FlexibleSpace();
            }

            GUILayout.Space(4);

            if (!m_LikelySupportsTextureBlending)
            {
                EditorGUILayout.HelpBox("It doesn't look like any of the materials on this object support texture blending!\n\nSee the readme for information on creating custom texture blend shaders.", MessageType.Warning);
            }

            // Selection dropdown for material (for submeshes)
            if (m_AvailableMaterialsAsString.Count() > 0)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUI.BeginChangeCheck();

                EditorGUILayout.LabelField("Material :", GUILayout.Width(60));
                currentMeshACIndex = EditorGUILayout.Popup(currentMeshACIndex, m_AvailableMaterialsAsString, "Popup");

                if (EditorGUI.EndChangeCheck())
                {
                    m_MeshAttributesContainer = m_MeshAttributesContainers[currentMeshACIndex];
                }

                EditorGUILayout.EndHorizontal();
            }

            GUILayout.Space(4);

            if (meshAttributes != null)
            {
                RefreshPreviewTextureCache();
                int prevSelectedAttributeIndex = m_SelectedAttributeIndex;
                m_SelectedAttributeIndex = SplatWeightEditor.OnInspectorGUI(m_SelectedAttributeIndex, ref brushColor, meshAttributes);
                if (prevSelectedAttributeIndex != m_SelectedAttributeIndex)
                {
                    SetBrushColorWithAttributeIndex(m_SelectedAttributeIndex);
                }

#if POLYBRUSH_DEBUG
                GUILayout.BeginHorizontal();

                GUILayout.FlexibleSpace();

                if (GUILayout.Button("MetaData", EditorStyles.miniButton))
                {
                    Debug.Log(meshAttributes.ToString("\n"));

                    string str = EditorUtility.FindPolybrushMetaDataForShader(meshAttributesContainer.shader);

                    if (!string.IsNullOrEmpty(str))
                    {
                        TextAsset asset = AssetDatabase.LoadAssetAtPath <TextAsset>(str);

                        if (asset != null)
                        {
                            EditorGUIUtility.PingObject(asset);
                        }
                        else
                        {
                            Debug.LogWarning("No MetaData found for Shader \"" + meshAttributesContainer.shader.name + "\"");
                        }
                    }
                    else
                    {
                        Debug.LogWarning("No MetaData found for Shader \"" + meshAttributesContainer.shader.name + "\"");
                    }
                }

                GUILayout.EndHorizontal();

                GUILayout.Space(4);

                if (GUILayout.Button("rebuild  targets"))
                {
                    RebuildColorTargets(brushColor, brushSettings.strength);
                }


                GUILayout.Label(brushColor != null ? brushColor.ToString() : "brush color: null\n");
#endif
            }
        }