static SortedDictionary <string, bool> GetHandledExtensionsByImporter(ScriptedImporterAttribute attribute) { var handledExts = new SortedDictionary <string, bool>(); if (attribute.fileExtensions != null) { #pragma warning disable 618 // AutoSelect is now obsolete, but in order to support user scripts still using it we need to read its value until we make it Obsolete error. var isDefault = attribute.AutoSelect; #pragma warning restore 618 for (var index = 0; index < attribute.fileExtensions.Length; index++) { var cleanExt = attribute.fileExtensions[index].Trim('.'); if (!string.IsNullOrEmpty(cleanExt)) { handledExts.Add(cleanExt, isDefault); } } } if (attribute.overrideFileExtensions != null) { for (var index = 0; index < attribute.overrideFileExtensions.Length; index++) { var cleanExt = attribute.overrideFileExtensions[index].Trim('.'); if (!string.IsNullOrEmpty(cleanExt)) { handledExts.Add(cleanExt, false); } } } return(handledExts); }
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); } } }
internal static void RegisterScriptedImporters() { ArrayList arrayList = AttributeHelper.FindEditorClassesWithAttribute(typeof(ScriptedImporterAttribute)); IEnumerator enumerator = arrayList.GetEnumerator(); try { while (enumerator.MoveNext()) { object current = enumerator.Current; Type type = current as Type; ScriptedImporterAttribute scriptedImporterAttribute = Attribute.GetCustomAttribute(type, typeof(ScriptedImporterAttribute)) as ScriptedImporterAttribute; SortedDictionary <string, bool> handledExtensionsByImporter = ScriptedImporter.GetHandledExtensionsByImporter(scriptedImporterAttribute); IEnumerator enumerator2 = arrayList.GetEnumerator(); try { while (enumerator2.MoveNext()) { object current2 = enumerator2.Current; if (current2 != current) { ScriptedImporterAttribute attribute = Attribute.GetCustomAttribute(current2 as Type, 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 as Type).FullName, current3.Key)); handledExtensionsByImporter.Remove(current3.Key); } } } } } finally { IDisposable disposable; if ((disposable = (enumerator2 as IDisposable)) != null) { disposable.Dispose(); } } foreach (KeyValuePair <string, bool> current4 in handledExtensionsByImporter) { AssetImporter.RegisterImporter(type, scriptedImporterAttribute.version, scriptedImporterAttribute.importQueuePriority, current4.Key); } } } finally { IDisposable disposable2; if ((disposable2 = (enumerator as IDisposable)) != null) { disposable2.Dispose(); } } }
static SortedDictionary <string, bool> GetHandledExtensionsByImporter(ScriptedImporterAttribute attribute) { var handledExts = new SortedDictionary <string, bool>(); if (attribute.fileExtensions != null) { foreach (var ext in attribute.fileExtensions) { var cleanExt = ext; if (cleanExt.StartsWith(".")) { cleanExt = cleanExt.Substring(1); } handledExts.Add(cleanExt, true); } } return(handledExts); }
private static SortedDictionary <string, bool> GetHandledExtensionsByImporter(ScriptedImporterAttribute attribute) { SortedDictionary <string, bool> sortedDictionary = new SortedDictionary <string, bool>(); if (attribute.fileExtensions != null) { string[] fileExtensions = attribute.fileExtensions; for (int i = 0; i < fileExtensions.Length; i++) { string text = fileExtensions[i]; string text2 = text; if (text2.StartsWith(".")) { text2 = text2.Substring(1); } sortedDictionary.Add(text2, true); } } return(sortedDictionary); }