public static void BuildMenu(GameObject canvas) { panel = new CanvasPanel(canvas, new Texture2D(1, 1), new Vector2(0, 0), Vector2.zero, new Rect(0, 0, 1, 1)); //panel.AddText("Panel Label", "Pick", new Vector2(0f, -20f), Vector2.zero, GUIController.Instance.trajanBold, 30); //pickupBorder var img_pickborder = GUIController.Instance.images["pickupBorder"]; var img_itemborder = GUIController.Instance.images["itemBorder"]; var img_selected = GUIController.Instance.images["selected"]; var img_defaultIcon = GUIController.Instance.images["defaultIcon"]; var img_savedborder = GUIController.Instance.images["savedBorder"]; panel.AddPanel("Border", img_pickborder, new Vector2((1920f - img_pickborder.width) / 2, 0), Vector2.zero, new Rect(0, 0, img_pickborder.width, img_pickborder.height)); Vector2 itemborderOffset = Vector2.zero; for (int i = 1; i <= ItemManager.GroupMax; i++) { var itemPanel = panel.GetPanel("Border").AddPanel($"ItemBorder{i}", img_itemborder, itemborderOffset, Vector2.zero, new Rect(0, 0, img_itemborder.width, img_itemborder.height)); itemPanel.AddButton($"Item_{i}", img_defaultIcon, Vector2.zero, Vector2.zero, ItemClicked, new Rect(0, 0, img_defaultIcon.width, img_defaultIcon.height), GUIController.Instance.arial, $"Item_{i}"); itemborderOffset.x += img_itemborder.width + 3f; } itemborderOffset.x += img_savedborder.width + 3f; var prefabPanel = panel.GetPanel("Border").AddPanel($"PrefabBorder{1}", img_savedborder, itemborderOffset, Vector2.zero, new Rect(0, 0, img_savedborder.width, img_savedborder.height)); prefabPanel.AddButton($"Prefab_{1}", img_defaultIcon, Vector2.zero, Vector2.zero, PrefabClicked, new Rect(0, 0, img_defaultIcon.width, img_defaultIcon.height), GUIController.Instance.arial, $"Prefab_{1}"); selected = panel.GetPanel("Border").AddImage("selected", img_selected, Vector2.zero, Vector2.zero, new Rect(0, 0, img_selected.width, img_selected.height)); ItemManager.Instance.GroupSwitchEventHandler += UpdateItemList; LogDebug("PickPanel Built"); }
public static void Focus(int i = 0) { var itemPanel = panel.GetPanel("Border").GetPanel($"ItemBorder{i}"); if (itemPanel == null) { return; } Vector2 pos = itemPanel.GetPosition(); selected.SetPosition(pos); current_focus = i; selected.SetActive(true); }