Пример #1
0
        internal override void OnEnable()
        {
            base.OnEnable();

            RefreshAvailablePalettes();
            if (prefabPalette == null)
            {
                prefabPalette = m_AvailablePalettes[0];
            }
            prefabLoadoutEditor = new PrefabLoadoutEditor(m_AvailablePalettes.ToList(), m_PrefabPalette);
        }
Пример #2
0
        private static void RemovedDeletedPrefabFromloadout()
        {
            // If the prefab paint mode is the current one in polybrush,
            // and the prefab that has just been deleted is in the loadout,
            // Need to remove it from there or error spam will occur
            PolybrushEditor editor = PolybrushEditor.instance;

            if (editor == null || editor.tool != BrushTool.Prefab)
            {
                return;
            }
            BrushModePrefab     brushMode     = (BrushModePrefab)editor.mode;
            PrefabLoadoutEditor loadouteditor = brushMode.prefabLoadoutEditor;

            if (loadouteditor == null)
            {
                return;
            }

            List <LoadoutInfo> toRemove = new List <LoadoutInfo>();

            foreach (LoadoutInfo info in loadouteditor.CurrentLoadout)
            {
                if (info.prefab == null)
                {
                    toRemove.Add(info);
                }
            }

            foreach (LoadoutInfo info in toRemove)
            {
                loadouteditor.RemovePrefabFromLoadout(info);
            }

            // Clear the list of selected items in the current PrefabPalette
            // NOTE: This is not ideal, but it's easier to make it this way for now
            // a solution would be to keep a reference to the deleted items before deleting them
            // then make a comparison with the new list, to keep selected only the ones that were
            // not deleted and refresh the indices of the selected list
            loadouteditor.prefabPaletteEditors[loadouteditor.currentPalette].selected.Clear();
        }