Exemplo n.º 1
0
        /// <summary>
        /// Makes sure we always have a valid BrushSettings selected in Polybrush then refresh the available list for the EditorWindow.
        /// Will create a new file if it cannot find any.
        /// </summary>
        internal void EnsureBrushSettingsListIsValid()
        {
            if (brushSettings == null)
            {
                if (brushSettingsAsset == null)
                {
                    brushSettingsAsset = BrushSettingsEditor.LoadBrushSettingsAssets(EditorPrefs.GetString(k_BrushSettingsAssetPref, ""));
                }

                if (EditorPrefs.HasKey(k_BrushSettingsPref))
                {
                    brushSettings = ScriptableObject.CreateInstance <BrushSettings>();
                    JsonUtility.FromJsonOverwrite(EditorPrefs.GetString(k_BrushSettingsPref), brushSettings);
                    if (EditorPrefs.HasKey(k_BrushSettingsName))
                    {
                        brushSettings.name = EditorPrefs.GetString(k_BrushSettingsName);
                    }
                }
                else
                {
                    SetBrushSettings(brushSettingsAsset != null ? brushSettingsAsset : PolyEditorUtility.GetFirstOrNew <BrushSettings>());
                }
            }

            m_AvailableBrushes = BrushSettingsEditor.GetAvailableBrushes();

            m_AvailableBrushesStrings = m_AvailableBrushes.Select(x => x.name).ToArray();
            m_CurrentBrushIndex       = System.Math.Max(Array.FindIndex <string>(m_AvailableBrushesStrings, x => x == brushSettings.name), 0);

            ArrayUtility.Add <string>(ref m_AvailableBrushesStrings, string.Empty);
            ArrayUtility.Add <string>(ref m_AvailableBrushesStrings, "Add Brush...");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Makes sure we always have a valid BrushSettings selected in Polybrush then refresh the available list for the EditorWindow.
        /// Will create a new file if it cannot find any.
        /// </summary>
        internal void EnsureBrushSettingsListIsValid()
        {
            VerifyLoadedBrushAssetsIntegrity();
            if (brushSettings == null)
            {
                if (brushSettingsAsset == null)
                {
                    brushSettingsAsset = BrushSettingsEditor.LoadBrushSettingsAssets(EditorPrefs.GetString(k_BrushSettingsAssetPref, ""));
                }

                if (EditorPrefs.HasKey(k_BrushSettingsPref) && brushSettingsAsset != null)
                {
                    brushSettings = ScriptableObject.CreateInstance <BrushSettings>();
                    JsonUtility.FromJsonOverwrite(EditorPrefs.GetString(k_BrushSettingsPref), brushSettings);
                    if (EditorPrefs.HasKey(k_BrushSettingsName))
                    {
                        brushSettings.name = EditorPrefs.GetString(k_BrushSettingsName);
                    }
                }
                else
                {
                    SetBrushSettings(brushSettingsAsset != null ? brushSettingsAsset : PolyEditorUtility.GetFirstOrNew <BrushSettings>());
                }
            }
        }