Ejemplo n.º 1
0
        protected BaseMightyMember(MightyContext context)
        {
            ID      = ReferencesUtilities.GetUniqueID(this);
            Context = context;

            WrappersInfo = new List <MightyWrapperInfo>();
        }
Ejemplo n.º 2
0
        public void OnEnable(Type type, Object context, object target, Func <string, SerializedProperty> findProperty,
                             bool isMonoScript, SerializedObject serializedObject)
        {
            m_isMonoScript = isMonoScript;

            if (isMonoScript && findProperty != null)
            {
                m_mightyContext = new MightyContext(this, context, findProperty("m_Script"), target);
            }
            else
            {
                m_mightyContext = new MightyContext(this, context, null, target);
            }

            HasMightyMembers = CacheClass(type, m_mightyContext);
            HasMightyMembers = CacheMembers(type, m_mightyContext, findProperty) || HasMightyMembers;

            EnableMembers();

            if (!isMonoScript)
            {
                return;
            }

            ApplyAutoValues();
            RefreshAllDrawers();
            if (serializedObject != null && serializedObject.hasModifiedProperties)
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
Ejemplo n.º 3
0
        private bool CacheClass(Type type, MightyContext context)
        {
            if (type.IsSubclassOf(typeof(BaseWrapperAttribute)) || !type.HasAttributeOfType <BaseClassAttribute>())
            {
                return(false);
            }

            m_classMember = new MightyMember <Type>(type, context);

            var wrappedAttributes = m_classMember.GetWrappedAttributes <BaseClassAttribute>();

            m_classMember.CacheClassDrawersForType(type, wrappedAttributes);

            return(true);
        }
Ejemplo n.º 4
0
        private MightyMethod CacheMethod(MethodInfo method, MightyContext context)
        {
            var mightyMethod = (MightyMethod)m_membersCache.Add(new MightyMethod(method, context));

            var wrappedAttributes = mightyMethod.GetWrappedAttributes <BaseMightyAttribute>();

            m_hasOrder = mightyMethod.CacheOrderDrawerForField(method, wrappedAttributes) || m_hasOrder;

            mightyMethod.CacheAnywhereDecoratorsForMember(method, wrappedAttributes);

            mightyMethod.CacheShowConditionForMember(method, wrappedAttributes);
            mightyMethod.CacheEnableConditionForMember(method, wrappedAttributes);

            mightyMethod.CacheMethodDrawerForMethod(method, wrappedAttributes);

            mightyMethod.CacheSimpleGrouperForField(method, wrappedAttributes);
            mightyMethod.CacheFoldableGrouperForField(method, wrappedAttributes);

            return(mightyMethod);
        }
Ejemplo n.º 5
0
        private MightyNativeProperty CacheNativeProperty(PropertyInfo property, MightyContext context)
        {
            var mightyProperty = (MightyNativeProperty)m_membersCache.Add(new MightyNativeProperty(property, context));

            var wrappedAttributes = mightyProperty.GetWrappedAttributes <BaseMightyAttribute>();

            m_hasOrder = mightyProperty.CacheOrderDrawerForField(property, wrappedAttributes) || m_hasOrder;

            mightyProperty.CacheShowConditionForMember(property, wrappedAttributes);
            mightyProperty.CacheEnableConditionForMember(property, wrappedAttributes);

            mightyProperty.CacheAnywhereDecoratorsForMember(property, wrappedAttributes);

            mightyProperty.CacheNativePropertyDrawerForProperty(property, wrappedAttributes);

            mightyProperty.CacheSimpleGrouperForField(property, wrappedAttributes);
            mightyProperty.CacheFoldableGrouperForField(property, wrappedAttributes);

            return(mightyProperty);
        }
Ejemplo n.º 6
0
        private MightyNonSerializedField CacheNonSerializedField(FieldInfo field, MightyContext context)
        {
            var mightyField = (MightyNonSerializedField)m_membersCache.Add(new MightyNonSerializedField(field, context));

            var wrappedAttributes = mightyField.GetWrappedAttributes <BaseMightyAttribute>();

            m_hasOrder = mightyField.CacheOrderDrawerForField(field, wrappedAttributes) || m_hasOrder;

            mightyField.CacheShowConditionForMember(field, wrappedAttributes);
            mightyField.CacheEnableConditionForMember(field, wrappedAttributes);

            mightyField.CacheAnywhereDecoratorsForMember(field, wrappedAttributes);

            mightyField.CacheNonSerializedDrawerForField(field, wrappedAttributes);

            mightyField.CacheSimpleGrouperForField(field, wrappedAttributes);
            mightyField.CacheFoldableGrouperForField(field, wrappedAttributes);

            return(mightyField);
        }
Ejemplo n.º 7
0
        private MightySerializedField CacheSerializedField(FieldInfo field, SerializedProperty property, MightyContext context)
        {
            m_serializedFieldCount++;

            var serializedField = (MightySerializedField)m_membersCache.Add(new MightySerializedField(property, field, context));

            var wrappedAttributes = serializedField.GetWrappedAttributes <BaseMightyAttribute>();

            m_hasOrder = serializedField.CacheOrderDrawerForField(field, wrappedAttributes) || m_hasOrder;

            serializedField.CacheAutoValueDrawerForField(field, wrappedAttributes);

            if ((hideStatus & HideStatus.SerializedFields) == HideStatus.SerializedFields)
            {
                return(serializedField);
            }

            serializedField.CacheShowConditionForMember(field, wrappedAttributes);
            serializedField.CacheEnableConditionForMember(field, wrappedAttributes);

            serializedField.CacheChangeCheckForField(field, wrappedAttributes);
            serializedField.CacheValidatorsForField(field, wrappedAttributes);

            serializedField.CacheGlobalDecoratorsForField(field, wrappedAttributes);

            serializedField.CachePropertyDrawerForField(field, wrappedAttributes);
            serializedField.CacheArrayDrawerForField(field, wrappedAttributes);

            serializedField.CacheSimpleGrouperForField(field, wrappedAttributes);
            serializedField.CacheFoldableGrouperForField(field, wrappedAttributes);

            return(serializedField);
        }
Ejemplo n.º 8
0
        private bool CacheMembers(Type type, MightyContext context, Func <string, SerializedProperty> findProperty)
        {
            var allMembers = ReflectionUtilities.GetAllMightyMembers(type, findProperty);

            var membersCount = allMembers.Length;

            if (membersCount == 0)
            {
                return(false);
            }

            Array.Sort(allMembers, (first, second) => first.info.GetMemberTypeOrder(first.property != null) -
                       second.info.GetMemberTypeOrder(second.property != null));

            m_membersCache = new MightyMembersCache();

            m_groupedMembersByGroup = new Dictionary <string, List <BaseMightyMember> >();
            m_drawnGroups           = new HashSet <string>();

            m_foldableGroupedMembersByGroup = new Dictionary <string, List <BaseMightyMember> >();
            m_drawnFoldableGroups           = new HashSet <string>();

            for (short i = 0; i < allMembers.Length; i++)
            {
                var(info, serializedProperty) = allMembers[i];
                BaseMightyMember mightyMember = null;
                switch (info)
                {
                case FieldInfo field:
                    if (serializedProperty != null)
                    {
                        mightyMember = CacheSerializedField(field, serializedProperty, context);
                    }
                    else
                    {
                        mightyMember = CacheNonSerializedField(field, context);
                    }
                    break;

                case PropertyInfo property:
                    mightyMember = CacheNativeProperty(property, context);
                    break;

                case MethodInfo method:
                    mightyMember = CacheMethod(method, context);
                    break;
                }

                if (mightyMember == null)
                {
                    continue;
                }

                mightyMember.DrawIndex = i;
            }

            if (m_hasOrder)
            {
                ReorderMembers();
            }

            return(true);
        }
Ejemplo n.º 9
0
 public MightyMethod(MethodInfo memberInfo, MightyContext context) : base(memberInfo, context)
 {
 }
Ejemplo n.º 10
0
 public MightyNativeProperty(PropertyInfo memberInfo, MightyContext context) : base(memberInfo, context)
 {
 }
Ejemplo n.º 11
0
 public MightyNonSerializedField(FieldInfo memberInfo, MightyContext context) : base(memberInfo, context)
 {
 }
Ejemplo n.º 12
0
 public MightySerializedField(SerializedProperty property, FieldInfo fieldInfo, MightyContext context) : base(fieldInfo, context)
 {
     Property     = property;
     PropertyType = property.GetSystemType();
 }
Ejemplo n.º 13
0
 public MightyMember(T memberInfo, MightyContext context) : base(context)
 {
     MemberInfo = memberInfo;
     MemberName = memberInfo.Name;
 }