/// <summary> /// Creates a button to display in the box hide menu from a given id. /// </summary> public void DisplayIcon(BoxHideInteractable obj, int id) { if (current_icons == 2) //Max number of icons { return; } BoxHideButton button = Instantiate(button_prefab) as BoxHideButton; button.transform.SetParent(transform, false); button.icon.sprite = obj.options[id].icon; button.function = obj.options[id].function; button.name = obj.options[id].name; //Seach free position if (current_icons == 0) { button.transform.localPosition = pos_A; } else { button.transform.localPosition = pos_B; } buttons.Add(button); current_icons++; }
public BoxHideMenu SpawnMenu(BoxHideInteractable obj, Vector3 spawn_position) { BoxHideMenu menu = Instantiate(menu_prefab) as BoxHideMenu; menu.transform.SetParent(transform, false); menu.transform.position = spawn_position; menu.box_object = obj; return(menu); }
BoxHideInteractable hide_inst; //Hide controller instance void Awake() { barion = GameObject.Find("Barion").GetComponent <BarionController>(); nyx = GameObject.Find("Nyx").GetComponent <NyxController>(); cosmo = GameObject.Find("Cosmo").GetComponent <CosmoController>(); selection_sys = GameObject.Find("SelectionSystem").GetComponent <UnitSelection>(); //Insert all menus in the dictionary RadialMenu_ObjectInteractable[] menus_scripts = GetComponents <RadialMenu_ObjectInteractable>(); foreach (RadialMenu_ObjectInteractable menu_script in menus_scripts) { menus.Add(menu_script.id, menu_script); } hide_inst = GetComponent <BoxHideInteractable>(); }
/// <summary> /// Removes a button in the box hide menu from a given id /// </summary> public void HideIcon(BoxHideInteractable obj, int id) { BoxHideButton button = buttons.Find(x => x.name == obj.options[id].name); //Find button to remove if (button != null) //Desired button to delete found { buttons.Remove(button); //Remove from list Destroy(button.gameObject); //Remove the object current_icons--; //Repositioning of the first icon to position A if (current_icons == 1) { buttons[0].transform.localPosition = pos_A; } if (current_icons == 0) //Remove the menu because no one is hide { HideMenu(); } } }