Example #1
0
        public virtual bool CanMatchSelector(SkinComponent skinComponent)
        {
            var otherSelectors = skinComponent.GetSelectors();

            if (otherSelectors == null || otherSelectors.Length == 0)
            {
                return(false);
            }

            if (selectors == null || selectors.Length == 0)
            {
                return(false);
            }

            switch (matchMethod)
            {
            case SelectorMatchMehod.Any:
                return(IsMatchAnySelector(otherSelectors));

            case SelectorMatchMehod.ExactlySame:
                return(IsMatchExactlySameSelector(otherSelectors));

            case SelectorMatchMehod.All:
            default:
                return(IsMatchAllSelector(otherSelectors));
            }
        }
Example #2
0
        void RenderGenericMenu(SkinManager skinManager)
        {
            GenericMenu menu = new GenericMenu();

            var possibleSelectors = skinManager.GetPossibleSelectors(targetComponent);
            var selectors         = targetComponent.GetSelectors();

            // remove redundant selectors
            for (int i = selectors.Length - 1; i >= 0; i--)
            {
                if (possibleSelectors.Contains(selectors[i]) == false)
                {
                    targetComponent.RemoveSelector(selectors[i]);
                }
            }

            for (int i = 0; i < possibleSelectors.Count; i++)
            {
                var selected = System.Array.IndexOf(selectors, possibleSelectors[i]) >= 0;
                menu.AddItem(new GUIContent(possibleSelectors[i]), selected, OnItemSelected, possibleSelectors[i]);
            }

            menu.ShowAsContext();
        }