public static void DoSelectTile(TileGridControl tileGridControl, int tileIdx) { tileGridControl.m_selectedTileIdx = tileIdx; EditorWindow wnd = EditorWindow.focusedWindow; TileSelectionWindow.Show(tileGridControl.Tileset); TileSelectionWindow.Instance.Ping(); wnd.Focus(); GUI.FocusControl(""); }
public override void OnEnable() { base.OnEnable(); m_brush = (BrushFortySeven)target; if (m_brushTileGridControl == null) { m_brushTileGridControl = new TileGridControl(target, 7, 7, BackgroundTexture, (int tileIdx) => { return(m_brush.TileIds[s_tileIdxMap[tileIdx]]); }, (int tileIdx, uint tileData) => { m_brush.TileIds[s_tileIdxMap[tileIdx]] = tileData; } ); m_brushTileGridControl.AllowBrushSelection = true; } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { TileDataAttribute tileDataAttrib = attribute as TileDataAttribute; if (property.propertyType != SerializedPropertyType.Integer) { Debug.LogError("SortedLayer property should be an integer"); } else { Tileset tileset = null; if (property.serializedObject.targetObject is MonoBehaviour) { STETilemap parentTilemap = (property.serializedObject.targetObject as MonoBehaviour).GetComponentInParent <STETilemap>(); if (parentTilemap) { tileset = parentTilemap.Tileset; } } else if (property.serializedObject.targetObject is TilesetBrush) { tileset = (property.serializedObject.targetObject as TilesetBrush).Tileset; } Rect rIntLabel = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); Rect rContent = new Rect(position.x, position.y + rIntLabel.height + 2f, position.width, position.height - rIntLabel.height); EditorGUI.PropertyField(rIntLabel, property, label); if (tileset) { Rect rVisualTile = EditorGUI.PrefixLabel(rContent, new GUIContent("Preview")); rVisualTile.width = rVisualTile.height = tileDataAttrib.tileSize; TileDataField(rVisualTile, label, property, tileset); if (tileDataAttrib.displayProperties) { Rect rTileProperties = new Rect(rVisualTile.xMax + 4f, rContent.y, rContent.width - rVisualTile.xMax - 4f, EditorGUIUtility.singleLineHeight); property.isExpanded = EditorGUI.Foldout(rTileProperties, property.isExpanded, "Tile Properties"); if (property.isExpanded) { rTileProperties.y += rTileProperties.height + 2f; rTileProperties.height = 90f; property.intValue = (int)TileGridControl.DoTileDataProperties(rTileProperties, (uint)property.intValue, tileset); } } } else { EditorGUI.HelpBox(rContent, "Tileset was not found!", MessageType.Warning); } } }