/** Toolbar Functions */ private void TagField() { GUIStyle style = _currentTag == null ? "Label" : "Button"; // Default tag if (GUILayout.Button("All", style)) { SetCurrentTag(null); } // Show all tags for (int i = 0; i < _config.GetTagCount(); i++) { Tag tag = _config.GetTagByIndex(i); bool isCurrentTag = _currentTag == tag; GUI.backgroundColor = tag.color; if (isCurrentTag) { if (i < 2) { GUILayout.Label(tag.name); } else { tag.name = GUILayout.TextField(tag.name); // Remove tag button if (GUILayout.Button("-")) { _config.RemoveTag(ref tag); } } } else { if (GUILayout.Button(tag.name)) { SetCurrentTag(tag); } } GUI.backgroundColor = Color.white; } // Add button if (GUILayout.Button("+")) { string defaultName = "NEW TAG"; Tag newTag = new Tag(defaultName, Color.white, _config.GetTagCount()); _config.AddTag(ref newTag); } }
/** Toolbar Functions */ private void TagField() { GUIStyle style = _currentTag == null ? "Label" : "Button"; // Default tag if (GUILayout.Button("All", style)) { SetCurrentTag(null); } // Show all tags for (int i = 0; i < _config.GetTagCount(); i++) { Tag tag = _config.GetTagByIndex(i); bool isCurrentTag = _currentTag == tag; GUI.backgroundColor = tag.color; if (isCurrentTag) { if (i < 2) { GUILayout.Label(tag.name); } else { tag.name = GUILayout.TextField(tag.name); GUIContent content = new GUIContent("-", "Remove this tag"); if (_currentGroups.Count > 0) { content.tooltip = "Can't remove this tag because it has an item."; GUI.enabled = false; } // Remove tag button if (GUILayout.Button(content)) { _config.RemoveTag(ref tag); } GUI.enabled = true; } } else { if (GUILayout.Button(tag.name)) { SetCurrentTag(tag); } } GUI.backgroundColor = Color.white; } // Add button GUIContent addButtonContent = new GUIContent("+", "Create a new tag"); if (GUILayout.Button(addButtonContent)) { string defaultName = "NEW TAG"; Tag newTag = new Tag(defaultName, Color.white, _config.GetTagCount()); _config.AddTag(ref newTag); } }