static internal BrushSettings[] GetAvailableBrushes()
        {
            List <BrushSettings> brushes = PolyEditorUtility.GetAll <BrushSettings>();

            if (brushes.Count < 1)
            {
                brushes.Add(PolyEditorUtility.GetFirstOrNew <BrushSettings>());
            }

            return(brushes.ToArray());
        }
        static internal IReadOnlyCollection <BrushSettings> GetAvailableBrushes()
        {
            List <BrushSettings> brushes = PolyEditorUtility.GetAll <BrushSettings>();

            if (brushes.Count < 1)
            {
                brushes.Add(PolyEditorUtility.GetFirstOrNew <BrushSettings>());
            }

            return(brushes);
        }
Exemple #3
0
        void RefreshAvailablePalettes()
        {
            m_AvailablePalettes = PolyEditorUtility.GetAll <PrefabPalette>().ToArray();

            if (m_AvailablePalettes.Length < 1)
            {
                prefabPalette = PolyEditorUtility.GetFirstOrNew <PrefabPalette>();
            }

            m_AvailablePalettesAsStrings = m_AvailablePalettes.Select(x => x.name).ToArray();
            ArrayUtility.Add <string>(ref m_AvailablePalettesAsStrings, string.Empty);
            ArrayUtility.Add <string>(ref m_AvailablePalettesAsStrings, "Add Palette...");
            m_CurrentPaletteIndex = System.Array.IndexOf(m_AvailablePalettes, m_PrefabPalette);
        }
        /// <summary>
        /// Refresh the list of available BrushSettings
        /// </summary>
        internal void RefreshAvailableBrushes()
        {
            m_AvailableBrushes = PolyEditorUtility.GetAll <BrushSettings>();

            if (m_AvailableBrushes.Count < 1)
            {
                m_AvailableBrushes.Add(PolyEditorUtility.GetFirstOrNew <BrushSettings>());
            }

            m_CurrentBrushIndex = System.Math.Max(m_AvailableBrushes.FindIndex(x => x.name.Equals(brushSettings.name)), 0);

            m_AvailableBrushesStrings = m_AvailableBrushes.Select(x => x.name).ToArray();

            ArrayUtility.Add <string>(ref m_AvailableBrushesStrings, string.Empty);
            ArrayUtility.Add <string>(ref m_AvailableBrushesStrings, "Add Brush...");
        }
Exemple #5
0
        internal static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            List <PrefabPalette> palettes = PolyEditorUtility.GetAll <PrefabPalette>();

            if (palettes.Count == 0 || deletedAssets.Length == 0)
            {
                return;
            }

            RemovedDeletedPrefabFromloadout();

            // Find out deleted prefabs and put them in a dictionnary to delete
            Dictionary <PrefabPalette, List <PrefabAndSettings> > toDelete = new Dictionary <PrefabPalette, List <PrefabAndSettings> >();

            foreach (PrefabPalette palette in palettes)
            {
                foreach (PrefabAndSettings settings in palette.prefabs)
                {
                    if (settings.gameObject == null)
                    {
                        if (!toDelete.ContainsKey(palette))
                        {
                            toDelete.Add(palette, new List <PrefabAndSettings>()
                            {
                                settings
                            });
                        }
                        else
                        {
                            toDelete[palette].Add(settings);
                        }
                    }
                }
            }

            // Delete the deleted prefabs from all the PrefabPalettes they were contained in
            foreach (PrefabPalette palette in toDelete.Keys)
            {
                foreach (PrefabAndSettings settings in toDelete[palette])
                {
                    palette.prefabs.Remove(settings);
                }
                EditorUtility.SetDirty(palette);
            }
        }