// ---------[ UTILITY ]--------- /// <summary>Checks a ModContainer's template structure.</summary> public static bool HasValidTemplate(ExplorerFilterTagsDropdown selector, out string helpMessage) { helpMessage = null; // - null checks - if (selector.categoryDisplay == null || !GameTagCategoryDisplay.HasValidTemplate(selector.categoryDisplay, out helpMessage)) { helpMessage = ("The required GameTagCategoryDisplay is missing or" + " has an invalid template."); return(false); } // - Validity checks - bool isValid = true; TagContainerItem tagItem = selector.categoryDisplay.template.tagTemplate; // check for StateToggleDisplay if (tagItem.gameObject.GetComponentInChildren <StateToggleDisplay>(true) == null) { helpMessage = ("This ExplorerFilterTagsDropdown has an invalid template." + "\nThe tag template of the GameTagCategoryDisplay must" + " also have a StateToggleDisplay derived component as" + " a child, or on the same GameObject." + "\n(EG. GameObjectToggle, StateToggle, or SlideToggle.)"); isValid = false; } return(isValid); }
// ---------[ INITIALIZATION ]--------- /// <summary>Set up the template.</summary> private void Awake() { // check template #if DEBUG string message; if (!ExplorerFilterTagsDropdown.HasValidTemplate(this, out message)) { Debug.LogError("[mod.io] " + message, this); return; } #endif this.categoryDisplay.onTagsChanged += (t) => this.UpdateSelectedTagsDisplay(this.m_selectedTags); }