A game about forced loneliness, made by TACStudios
1using System;
2using UnityEngine;
3using UnityEngine.UIElements;
4
5namespace UnityEditor.Tilemaps
6{
7 internal class TilePaletteCreateTargetsDropdownMenu : IGenericMenu
8 {
9 private const float k_DropdownWidth = 156f;
10
11 private GridPaintCreateTargetsDropdown m_Dropdown;
12
13 private Action m_OnClose;
14
15 private bool m_HasTilePalette;
16
17 public TilePaletteCreateTargetsDropdownMenu(Action onClose)
18 {
19 m_HasTilePalette = GridPaintingState.palette != null;
20 var index = -1;
21 var menuData = new GridPaintCreateTargetsDropdown.MenuItemProvider(m_HasTilePalette);
22 m_Dropdown = new GridPaintCreateTargetsDropdown(menuData, index, null, CreateTilemapTarget, k_DropdownWidth);
23 m_OnClose = onClose;
24 }
25
26 public void AddItem(string itemName, bool isChecked, System.Action action)
27 {
28 }
29
30 public void AddItem(string itemName, bool isChecked, System.Action<object> action, object data)
31 {
32 }
33
34 public void AddDisabledItem(string itemName, bool isChecked)
35 {
36 }
37
38 public void AddSeparator(string path)
39 {
40 }
41
42 public void DropDown(Rect position, VisualElement targetElement = null, bool anchored = false)
43 {
44 PopupWindow.Show(position, m_Dropdown, null, ShowMode.PopupMenu);
45 }
46
47 public void Close()
48 {
49 PopupWindow.Show(default, m_Dropdown, null, ShowMode.PopupMenu);
50 }
51
52 private void CreateTilemapTarget(int i, object o)
53 {
54 m_Dropdown.editorWindow.Close();
55 if (!m_HasTilePalette)
56 i += 1;
57 GameObjectCreation.CreateTilemapTargets(i);
58 m_OnClose?.Invoke();
59 GUIUtility.ExitGUI();
60 }
61 }
62}