private Utils.ButtonState DisableIf(bool value, Utils.ButtonState state) { if (value) { return(Utils.ButtonState.Disable); } else if (state == Utils.ButtonState.Disable) { return(Utils.ButtonState.None); } return(state); }
public void DrawTagsBtnsLayout(bool disabled) { Rect rect = GUILayoutUtility.GetRect(Screen.width, 50).Shrink(10); Rect btnRect = rect; //Update disable state of buttons based on selection breakBtn = DisableIf(haveSelection, breakBtn); emotionBtn = DisableIf(!haveSelection, emotionBtn); editBtn = DisableIf(haveSelection || !containsTag, editBtn); removeBtn = DisableIf(!containsTag, removeBtn); //Break button btnRect.width = 60; if (Utils.FlatButton(btnRect, new GUIContent(Resources.instance.breakIco), new Color(0.956f, 0.361f, 0.259f), ref breakBtn)) { tagToEdit = text.AddBreak(); } //Emotion button btnRect.Set(btnRect.x + btnRect.width + 5, btnRect.y, 130, btnRect.height); if (Utils.FlatButton(btnRect, new GUIContent("Add Emotion"), new Color(0.259f, 0.6f, 0.956f), ref emotionBtn)) { tagToEdit = text.AddTag(); } btnRect.Set(btnRect.x + btnRect.width + 5, btnRect.y, 70, btnRect.height); if (Utils.FlatButton(btnRect, new GUIContent("Edit"), new Color(0.259f, 0.6f, 0.956f), ref editBtn)) { tagToEdit = text.GetTag(); } btnRect.Set(btnRect.x + btnRect.width + 5, btnRect.y, 100, btnRect.height); if (Utils.FlatButton(btnRect, new GUIContent("Remove"), new Color(1.0f, 0.6f, 0.1f), ref removeBtn)) { if (text.haveSelection) { text.RemoveTag(); } else { text.RemoveTag(text.GetTag()); } } }