示例#1
0
        public static MDAttribute GetMDAttribute(string value)
        {
            MDAttribute attr = null;

            _mdAttributes.TryGetValue(value, out attr);
            return(attr);
        }
示例#2
0
        public virtual void Init()
        {
            rectTransform.anchoredPosition = Vector2.zero;

            foreach (KeyValuePair <string, string> arg in attributeArgs)
            {
                MDAttribute mdAttribute = View.GetMDAttribute(arg.Key.ToLower());
                if (mdAttribute == null)
                {
                    continue;
                }
                var attributes = mdAttribute.GetType().GetCustomAttributes(typeof(ExpectComponent), true);
                if (attributes == null || attributes.Length == 0)
                {
                    continue;
                }
                var attrType = ((ExpectComponent)attributes[0]).component;

                // clean me...
                if (attrType == typeof(UnityEngine.Component) ||
                    attrType.BaseType == typeof(UnityEngine.UI.Shadow) ||
                    attrType.BaseType == typeof(UnityEngine.UI.MaskableGraphic) ||
                    attrType.BaseType == typeof(UnityEngine.Transform) ||
                    attrType.BaseType == typeof(UnityEngine.UI.Selectable) ||
                    attrType.BaseType.BaseType == typeof(UnityEngine.UI.LayoutGroup))
                {
                    mdAttribute.Apply(gameObject.GetComponent(
                                          ((ExpectComponent)attributes[0]).component), arg.Value.Split(','));
                }
                else if (attrType == typeof(Element))
                {
                    mdAttribute.Apply(this, arg.Value.Split(','));
                }
            }
        }