Exemple #1
0
 /// <summary>
 /// Verify if all loaded assets haven't been touched by users.
 /// If one or multiples assets are missing, refresh the Palettes list and loadouts.
 /// </summary>
 void VerifyLoadedBrushAssetsIntegrity()
 {
     if (m_AvailableBrushes != null && m_AvailableBrushes.Length > 0 &&
         !System.Array.TrueForAll(m_AvailableBrushes, x => x != null))
     {
         RefreshAvailableBrushList();
         m_CurrentBrushIndex = 0;
         if (m_AvailableBrushes.Length > 0)
         {
             SetBrushSettings(m_AvailableBrushes[m_CurrentBrushIndex]);
         }
         else
         {
             SetBrushSettings(BrushSettingsEditor.AddNew(brushSettings));
         }
     }
 }
        void DrawBrushSettings()
        {
            // Brush preset selector
            using (new GUILayout.VerticalScope("box"))
            {
                // Show the settings header in PolyEditor so that the preset selector can be included in the block.
                // Can't move preset selector to BrushSettingsEditor because it's a CustomEditor for BrushSettings,
                // along with other issues.
                if (PolyGUILayout.HeaderWithDocsLink(PolyGUI.TempContent("Brush Settings")))
                {
                    Application.OpenURL(PrefUtility.documentationBrushSettingsLink);
                }

                using (new GUILayout.HorizontalScope())
                {
                    EditorGUI.BeginChangeCheck();

                    m_CurrentBrushIndex = EditorGUILayout.Popup(m_CurrentBrushIndex, m_AvailableBrushesStrings, "Popup");

                    if (EditorGUI.EndChangeCheck())
                    {
                        if (m_CurrentBrushIndex >= m_AvailableBrushes.Count)
                        {
                            SetBrushSettings(BrushSettingsEditor.AddNew(brushSettings));
                        }
                        else
                        {
                            SetBrushSettings(m_AvailableBrushes[m_CurrentBrushIndex]);
                        }
                    }

                    if (GUILayout.Button(m_GCSaveBrushSettings, GUILayout.Width(40)))
                    {
                        if (brushSettings != null && brushSettingsAsset != null)
                        {
                            // integer 0, 1 or 2 corresponding to ok, cancel and alt buttons
                            int res = EditorUtility.DisplayDialogComplex("Save Brush Settings", "Overwrite brush preset, or Create a New brush preset? ", "Overwrite", "Create New", "Cancel");

                            if (res == 0)
                            {
                                brushSettings.CopyTo(brushSettingsAsset);
                                EditorGUIUtility.PingObject(brushSettingsAsset);
                            }
                            else if (res == 1)
                            {
                                BrushSettings dup = BrushSettingsEditor.AddNew(brushSettings);
                                SetBrushSettings(dup);
                                EditorGUIUtility.PingObject(brushSettingsAsset);
                            }
                        }
                        else
                        {
                            Debug.LogWarning("Something went wrong saving brush settings.");
                        }
                    }
                }
                EditorGUI.BeginChangeCheck();

                brushEditor.OnInspectorGUI();
            }
        }