using System; using System.Collections.Generic; using UnityEditor.U2D; using UnityEditor.UIElements; using UnityEngine; using UnityEngine.U2D; using UnityEngine.UIElements; namespace UnityEditor.Tilemaps { internal class TileSetImporterElement : VisualElement { private static class Styles { public static readonly string textureSourcesTooltip = L10n.Tr("The list of sprite textures and Tile Templates that create Tiles for the Tile Set."); public static readonly string paletteGridTooltip = L10n.Tr("Settings for the Tile Palette the Tile Set creates."); public static readonly string cellLayoutTooltip = L10n.Tr("Sets the grid layout for the Tile Palette that Unity creates."); public static readonly string hexagonLayoutTooltip = L10n.Tr("Sets the layout of the Tile Palette if you set Cell Layout to Hexagon."); public static readonly string cellSizingTooltip = L10n.Tr("Controls the size of the cell you paint a tile on."); public static readonly string cellSizeTooltip = L10n.Tr("Sets the size of the cell you paint a tile on."); public static readonly string cellGapTooltip = L10n.Tr("Sets the gap of between cells you paint a tile on."); public static readonly string sortAxisTooltip = L10n.Tr("Sets the x-axis, y-axis, and z-axis of the sorting axis."); public static readonly string sortModeTooltip = L10n.Tr("Determines the transparency sort mode of renderers in the Tile Palette."); public static readonly string createAtlasTooltip = L10n.Tr("If enabled, Unity creates a Sprite Atlas, and atlases the textures in Tile Set."); public static readonly string spriteAtlasTooltip = L10n.Tr("Settings for the Sprite Atlas Unity creates."); } public Action onRevert; public Action onApply; private SerializedObject asset; private SerializedObject importer; private ListView listView; private PropertyField cellLayoutField; private PropertyField hexagonLayoutField; private PropertyField cellSizingField; private PropertyField cellSizeField; private PropertyField cellGapField; private PropertyField sortAxisField; private PropertyField sortModeField; private PropertyField createAtlasField; private VisualElement spriteAtlasEditorRoot; private PropertyField scriptablePackerElement; private Label spriteAtlasLabel; private VisualElement applyRevertHe; private VisualElement tracker; private SpriteAtlas spriteAtlas; private Editor spriteAtlasEditor; public TileSetImporterElement(SerializedObject inImporter) { importer = inImporter; var openTilePaletteButton = new Button(OpenTilePaletteWindow); openTilePaletteButton.text = "Open Tile Palette Window"; Add(openTilePaletteButton); var gridFoldout = new Foldout(); gridFoldout.Bind(importer); gridFoldout.bindingPath = "paletteGridFoldout"; gridFoldout.text = "Palette Grid"; gridFoldout.Q().tooltip = Styles.paletteGridTooltip; cellLayoutField = new PropertyField() { bindingPath = "m_CellLayout", tooltip = Styles.cellLayoutTooltip, }; hexagonLayoutField = new PropertyField { bindingPath = "m_HexagonLayout", tooltip = Styles.hexagonLayoutTooltip, }; cellSizeField = new PropertyField { bindingPath = "m_CellSize", tooltip = Styles.cellSizeTooltip, }; cellGapField = new PropertyField { bindingPath = "m_CellGap", tooltip = Styles.cellGapTooltip, }; cellSizingField = new PropertyField { bindingPath = "m_CellSizing", tooltip = Styles.cellSizingTooltip, }; sortModeField = new PropertyField { bindingPath = "m_TransparencySortMode", tooltip = Styles.sortModeTooltip, }; sortAxisField = new PropertyField { bindingPath = "m_TransparencySortAxis", tooltip = Styles.sortAxisTooltip, }; gridFoldout.Add(cellLayoutField); gridFoldout.Add(hexagonLayoutField); gridFoldout.Add(cellSizingField); gridFoldout.Add(cellSizeField); gridFoldout.Add(cellGapField); gridFoldout.Add(sortModeField); gridFoldout.Add(sortAxisField); listView = new ListView() { bindingPath = "m_TextureSources" , showAddRemoveFooter = true , showBorder = true , showAlternatingRowBackgrounds = AlternatingRowBackground.ContentOnly , showBoundCollectionSize = false , showFoldoutHeader = true , reorderable = true , reorderMode = ListViewReorderMode.Animated , horizontalScrollingEnabled = false , headerTitle = "Texture Sources" , virtualizationMethod = CollectionVirtualizationMethod.DynamicHeight }; Add(listView); var manipulator = new TileSetImporterDragAndDropManipulator( () => true, OnDragPerform); var toggle = listView.Q().Q