private static void GetUserSortingComparers()
        {
            m_SortingMethods = new List <MethodInfo>();
            foreach (var sortingMethod in EditorAssemblies.GetAllMethodsWithAttribute <GridPaintSortingAttribute>())
            {
                if (!sortingMethod.ReturnType.IsAssignableFrom(typeof(IComparer <GameObject>)))
                {
                    continue;
                }
                if (sortingMethod.GetGenericArguments().Length > 0)
                {
                    continue;
                }
                m_SortingMethods.Add(sortingMethod);
            }

            m_SortingTypes = new List <Type>();
            foreach (var sortingType in EditorAssemblies.GetAllTypesWithAttribute <GridPaintSortingAttribute>())
            {
                if (sortingType.IsAbstract)
                {
                    continue;
                }
                m_SortingTypes.Add(sortingType);
            }
        }
Ejemplo n.º 2
0
        internal static void RegisterScriptedImporters()
        {
            IEnumerable <Type> allTypesWithAttribute = EditorAssemblies.GetAllTypesWithAttribute <ScriptedImporterAttribute>();

            foreach (Type current in allTypesWithAttribute)
            {
                Type type = current;
                ScriptedImporterAttribute       scriptedImporterAttribute   = Attribute.GetCustomAttribute(type, typeof(ScriptedImporterAttribute)) as ScriptedImporterAttribute;
                SortedDictionary <string, bool> handledExtensionsByImporter = ScriptedImporter.GetHandledExtensionsByImporter(scriptedImporterAttribute);
                foreach (Type current2 in allTypesWithAttribute)
                {
                    if (current2 != current)
                    {
                        ScriptedImporterAttribute       attribute = Attribute.GetCustomAttribute(current2, typeof(ScriptedImporterAttribute)) as ScriptedImporterAttribute;
                        SortedDictionary <string, bool> handledExtensionsByImporter2 = ScriptedImporter.GetHandledExtensionsByImporter(attribute);
                        foreach (KeyValuePair <string, bool> current3 in handledExtensionsByImporter2)
                        {
                            if (handledExtensionsByImporter.ContainsKey(current3.Key))
                            {
                                Debug.LogError(string.Format("Scripted importers {0} and {1} are targeting the {2} extension, rejecting both.", type.FullName, current2.FullName, current3.Key));
                                handledExtensionsByImporter.Remove(current3.Key);
                            }
                        }
                    }
                }
                MethodInfo method = type.GetMethod("GetHashOfImportedAssetDependencyHintsForTesting", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
                foreach (KeyValuePair <string, bool> current4 in handledExtensionsByImporter)
                {
                    AssetImporter.RegisterImporter(type, scriptedImporterAttribute.version, scriptedImporterAttribute.importQueuePriority, current4.Key, method != null);
                }
            }
        }
Ejemplo n.º 3
0
        internal static void RegisterScriptedImporters()
        {
            var importers = EditorAssemblies.GetAllTypesWithAttribute <ScriptedImporterAttribute>();

            foreach (var importer in importers)
            {
                var importerType = importer as Type;
                var attribute    = Attribute.GetCustomAttribute(importerType, typeof(ScriptedImporterAttribute)) as ScriptedImporterAttribute;
                var handledExts  = GetHandledExtensionsByImporter(attribute);

                // Prevent duplicates between importers! When duplicates found: all are rejected
                foreach (var imp in importers)
                {
                    if (imp == importer)
                    {
                        continue;
                    }

                    var attribute2   = Attribute.GetCustomAttribute(imp as Type, typeof(ScriptedImporterAttribute)) as ScriptedImporterAttribute;
                    var handledExts2 = GetHandledExtensionsByImporter(attribute2);

                    // Remove intersection?
                    foreach (var x1 in handledExts2)
                    {
                        if (handledExts.ContainsKey(x1.Key))
                        {
                            // Log error message and remove from handledExts
                            Debug.LogError(String.Format("Scripted importers {0} and {1} are targeting the {2} extension, rejecting both.", importerType.FullName, (imp as Type).FullName, x1.Key));
                            handledExts.Remove(x1.Key);
                        }
                    }
                }

                var supportsImportDependencyHinting = importerType.GetMethod("GetHashOfImportedAssetDependencyHintsForTesting", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static) != null ||
                                                      importerType.GetMethod("GatherDependenciesFromSourceFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static) != null;

                // Register the importer
                foreach (var ext in handledExts)
                {
                    AssetImporter.RegisterImporter(importerType, attribute.version, attribute.importQueuePriority, ext.Key, supportsImportDependencyHinting);
                }
            }
        }
        public static Type GetDefaultBrushType()
        {
            Type defaultType = typeof(GridBrush);
            int  count       = 0;

            foreach (var type in EditorAssemblies.GetAllTypesWithAttribute <CustomGridBrushAttribute>())
            {
                var attrs = type.GetCustomAttributes(typeof(CustomGridBrushAttribute), false) as CustomGridBrushAttribute[];
                if (attrs != null && attrs.Length > 0)
                {
                    if (attrs[0].defaultBrush)
                    {
                        defaultType = type;
                        count++;
                    }
                }
            }
            if (count > 1)
            {
                Debug.LogWarning("Multiple occurrences of defaultBrush == true found. It should only be declared once.");
            }
            return(defaultType);
        }