コード例 #1
0
        // ---------[ UTILITY ]---------
        /// <summary>Checks a ModContainer's template structure.</summary>
        public static bool HasValidTemplate(ExplorerFilterTagsSelector 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 ExplorerFilterTagsSelector 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);
        }
コード例 #2
0
        // ---------[ INITIALIZATION ]---------
        /// <summary>Set up the template.</summary>
        private void Awake()
        {
            // check template
            #if DEBUG
            string message;
            if (!ExplorerFilterTagsSelector.HasValidTemplate(this, out message))
            {
                Debug.LogError("[mod.io] " + message, this);
                return;
            }
            #endif

            this.categoryDisplay.onTagsChanged += (t) => this.UpdateSelectedTagsDisplay(this.m_selectedTags);
        }