コード例 #1
0
        /// <summary>
        /// Gets a list of <see cref="OdinAttributeProcessor"/> to process attributes for the specified property.
        /// </summary>
        /// <param name="property">The property to find attribute porcessors for.</param>
        /// <returns>List of <see cref="OdinAttributeProcessor"/> to process attributes for the speicied member.</returns>
        public override List <OdinAttributeProcessor> GetSelfProcessors(InspectorProperty property)
        {
            List <OdinAttributeProcessor> processors = new List <OdinAttributeProcessor>();

            CachedMatchesList.Clear();
            CachedMatchesList.Add(SearchIndex.GetMatches(Type.EmptyTypes));

            if (property.ValueEntry != null)
            {
                CachedMatchesList.Add(SearchIndex.GetMatches(property.ValueEntry.TypeOfValue));
            }

            var results = TypeSearchIndex.GetCachedMergedQueryResults(CachedMatchesList);

            for (int i = 0; i < results.Length; i++)
            {
                var result   = results[i];
                var resolver = GetResolverInstance(result.MatchedType);

                if (resolver.CanProcessSelfAttributes(property))
                {
                    processors.Add(resolver);
                }
            }

            return(processors);
        }
コード例 #2
0
ファイル: DrawerUtilities.cs プロジェクト: treert/om.unity.xx
        public static void GetDefaultPropertyDrawers(InspectorProperty property, List <TypeSearchResult> resultList)
        {
            resultList.Clear();

            var queries = CachedQueryResultList;

            queries.Clear();

            // First we make and gather lots of small queries, which are essentially instant, as they are
            //  all cached by the search index.
            {
                // Empty query (for all drawers with no type constraints at all)
                queries.Add(SearchIndex.GetMatches(Type.EmptyTypes));

                // Value query
                if (property.ValueEntry != null)
                {
                    queries.Add(SearchIndex.GetMatches(property.ValueEntry.TypeOfValue));
                }

                // Attribute queries
                for (int i = 0; i < property.Attributes.Count; i++)
                {
                    var attr = property.Attributes[i].GetType();
                    queries.Add(SearchIndex.GetMatches(attr));

                    // Attribute and value query
                    if (property.ValueEntry != null)
                    {
                        queries.Add(SearchIndex.GetMatches(attr, property.ValueEntry.TypeOfValue));

                        if (InvalidAttributeTargetUtility.ShowInvalidAttributeErrorFor(property, attr))
                        {
                            queries.Add(GetInvalidAttributeTypeSearchResult(attr));
                        }
                    }
                }
            }

            var finalResults = TypeSearchIndex.GetCachedMergedQueryResults(queries);

            // Build up the final result list, filtering invalid drawer types away
            //  as we go.
            for (int i = 0; i < finalResults.Length; i++)
            {
                var result = finalResults[i];

                if (DrawerTypeCanDrawProperty(result.MatchedType, property))
                {
                    resultList.Add(finalResults[i]);
                }
            }
        }
コード例 #3
0
        public static List <OdinPropertyProcessor> GetMemberProcessors(InspectorProperty property)
        {
            var queries = CachedQueryList;

            queries.Clear();

            //var results = CachedResultList;
            //results.Clear();

            queries.Add(SearchIndex.GetMatches(Type.EmptyTypes));

            if (property.ValueEntry != null)
            {
                var valueType = property.ValueEntry.TypeOfValue;

                queries.Add(SearchIndex.GetMatches(valueType));

                for (int i = 0; i < property.Attributes.Count; i++)
                {
                    queries.Add(SearchIndex.GetMatches(valueType, property.Attributes[i].GetType()));
                }
            }

            var results = TypeSearchIndex.GetCachedMergedQueryResults(queries);

            List <OdinPropertyProcessor> processors = new List <OdinPropertyProcessor>();

            for (int i = 0; i < results.Length; i++)
            {
                var result = results[i];
                if (GetEmptyInstance(result.MatchedType).CanProcessForProperty(property))
                {
                    processors.Add(OdinPropertyProcessor.Create(result.MatchedType, property));
                }
            }

            return(processors);
        }
コード例 #4
0
ファイル: DrawerUtilities.cs プロジェクト: treert/om.unity.xx
        public static IEnumerable <TypeSearchResult> GetDefaultPropertyDrawers(InspectorProperty property)
        {
            var queries = CachedQueryResultList;

            queries.Clear();

            // First we make and gather lots of small queries, which are essentially instant, as they are
            //  all cached by the search index.
            {
                // Empty query (for all drawers with no type constraints at all)
                queries.Add(SearchIndex.GetMatches(Type.EmptyTypes));

                // Value query
                if (property.ValueEntry != null)
                {
                    queries.Add(SearchIndex.GetMatches(property.ValueEntry.TypeOfValue));
                }

                // Attribute queries
                for (int i = 0; i < property.Attributes.Count; i++)
                {
                    var attr = property.Attributes[i].GetType();
                    queries.Add(SearchIndex.GetMatches(attr));

                    // Attribute and value query
                    if (property.ValueEntry != null)
                    {
                        queries.Add(SearchIndex.GetMatches(attr, property.ValueEntry.TypeOfValue));

                        if (InvalidAttributeTargetUtility.ShowInvalidAttributeErrorFor(property, attr))
                        {
                            queries.Add(new TypeSearchResult[]
                            {
                                new TypeSearchResult()
                                {
                                    MatchedInfo = new TypeSearchInfo()
                                    {
                                        MatchType = typeof(InvalidAttributeNotificationDrawer <>),
                                        Priority  = double.MaxValue,
                                        Targets   = Type.EmptyTypes
                                    },
                                    MatchedRule    = InvalidAttributeRule,
                                    MatchedTargets = Type.EmptyTypes,
                                    MatchedType    = typeof(InvalidAttributeNotificationDrawer <>).MakeGenericType(attr)
                                }
                            });
                        }
                    }
                }
            }

            var finalResults = TypeSearchIndex.GetCachedMergedQueryResults(queries);

            // Yield the final result array, filtering invalid drawer types away
            //  as we go.
            for (int i = 0; i < finalResults.Length; i++)
            {
                var result = finalResults[i];

                if (DrawerTypeCanDrawProperty(result.MatchedType, property))
                {
                    yield return(finalResults[i]);
                }
            }
        }