//remove button from UI public void RemoveButton(KeyValuePair <string, AlimentState> keyToRemove) { KeyValuePair <ColdRoom_Button, KeyValuePair <string, AlimentState> > toDel = buttons.First(x => x.Value.Equals(keyToRemove)); if (selectedButton == toDel.Key) { selectedButton = null; } Destroy(toDel.Key.gameObject); buttons.Remove(toDel.Key); }
//remove button from UI public bool RemoveButton(out KeyValuePair <string, AlimentState> keyToRemove) { if (selectedButton != null) { keyToRemove = buttons[selectedButton]; Destroy(selectedButton.gameObject); buttons.Remove(selectedButton); selectedButton = null; return(true); } return(false); }
public void DisplayChoiceMenu(ColdRoom_Button _button) { AlimentState alimentState = buttons[_button].Value; if (alimentState == AlimentState.Box || alimentState == AlimentState.Stack) { buttonTakeOne.interactable = true; buttonTakeAll.interactable = true; } else { buttonTakeOne.interactable = true; buttonTakeAll.interactable = false; } }
//add button in dictionnary and UI with good sprite public void AddButton(KeyValuePair <string, AlimentState> _keyFood) { if (!buttons.ContainsValue(_keyFood)) { ColdRoom_Button newButton = (Instantiate(buttonPrefab, buttonsContent) as GameObject).GetComponent <ColdRoom_Button>(); Sprite sprite = FoodDatabase.mapSpriteAliment[_keyFood]; if (sprite == null) { Debug.LogError("Sprite for button not found"); } newButton.Init(this, sprite); buttons.Add(newButton, _keyFood); } }
// selectedButton = button click public void SetSelectedButton(ColdRoom_Button _button) { selectedButton = _button; }