示例#1
0
        public static bool GetInfoFromMember <T>(this BaseMightyMember mightyMember, object target, string memberName,
                                                 out MightyInfo <T> info, GetValuePredicate <T> predicate = null, bool neverInWrapper = false)
        {
            if (string.IsNullOrWhiteSpace(memberName))
            {
                info = null;
                return(false);
            }

            if (predicate != null && predicate(memberName, out var outValue))
            {
                info = new MightyInfo <T>(null, null, outValue);
                return(true);
            }

            if (target is BaseWrapperAttribute wrapper)
            {
                if (neverInWrapper)
                {
                    return(mightyMember.GetInfoFromMember(mightyMember.GetWrapperTarget(wrapper), memberName, out info, predicate));
                }
                if (GetCallbackName(target, memberName, out var callbackName))
                {
                    return(mightyMember.GetInfoFromMember(mightyMember.GetWrapperTarget(wrapper), callbackName, out info, predicate));
                }
            }

            if (InternalGetInfoFromMember(target, memberName, true, out info))
            {
                return(true);
            }

            if (!(mightyMember is MightySerializedField serializedField))
            {
                return(false);
            }

            target = serializedField.Property.GetPropertyTargetReference();
            if (target.GetType().GetCustomAttributes(typeof(SerializableAttribute), true).Length > 0 &&
                InternalGetInfoFromMember(target, memberName, true, out info))
            {
                return(true);
            }


            if (!TypeUtilities.TryConvertStringToType(memberName, out T value))
            {
                return(false);
            }

            info = new MightyInfo <T>(target, null, value);
            return(true);
        }
示例#2
0
        protected override void Enable(BaseMightyMember mightyMember, T attribute)
        {
            if (!mightyMember.GetInfoFromMember <ArrayDecoratorPosition>(attribute.Target, attribute.PositionCallback, out var positionInfo,
                                                                         Enum.TryParse))
            {
                positionInfo = new MightyInfo <ArrayDecoratorPosition>(attribute.Position);
            }

            m_positionCache[mightyMember] = positionInfo;
        }
示例#3
0
        public static MightyInfo <GUIStyle> GetStyleInfo(this BaseMightyMember mightyMember, object target, string styleName,
                                                         out bool exception)
        {
            var ex = false;

            if (string.IsNullOrEmpty(styleName) || !mightyMember.GetInfoFromMember(target, styleName, out var styleInfo,
                                                                                   (string name, out GUIStyle value) => GetStyle(name, out value, out ex)))
            {
                exception = ex;
                return(null);
            }

            exception = ex;
            return(styleInfo);
        }
示例#4
0
        protected override void Enable(BaseMightyMember mightyMember, T attribute)
        {
            if (!(mightyMember is MightyComponent mightyComponent))
            {
                return;
            }

            var gameObject = mightyComponent.ComponentContext.GameObject;

            if (!mightyMember.GetInfoFromMember <int>(attribute.Target, attribute.PriorityCallback, out var priorityInfo))
            {
                priorityInfo = new MightyInfo <int>(attribute.Priority);
            }

            if (m_priorityCache.TryGetValue(gameObject, out var priority) && priority.Value >= priorityInfo.Value)
            {
                return;
            }

            m_priorityCache[gameObject] = priorityInfo;
            EnableDrawerImpl(mightyComponent, attribute);
        }
示例#5
0
 public static bool GetBoolInfo(this BaseMightyMember mightyMember, object target, string memberName, out MightyInfo <bool> info)
 => mightyMember.GetInfoFromMember(target, memberName, out info,
                                   (string name, out bool value) => bool.TryParse(name, out value));