ABDataSourceProvider.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reflection;
  5. namespace AssetBundleBrowser.AssetBundleDataSource
  6. {
  7. internal class ABDataSourceProviderUtility {
  8. private static List<Type> s_customNodes;
  9. internal static List<Type> CustomABDataSourceTypes {
  10. get {
  11. if(s_customNodes == null) {
  12. s_customNodes = BuildCustomABDataSourceList();
  13. }
  14. return s_customNodes;
  15. }
  16. }
  17. private static List<Type> BuildCustomABDataSourceList()
  18. {
  19. var properList = new List<Type>();
  20. properList.Add(null); //empty spot for "default"
  21. var x = AppDomain.CurrentDomain.GetAssemblies();
  22. foreach (var assembly in x)
  23. {
  24. try
  25. {
  26. var list = new List<Type>(
  27. assembly
  28. .GetTypes()
  29. .Where(t => t != typeof(ABDataSource))
  30. .Where(t => typeof(ABDataSource).IsAssignableFrom(t)));
  31. for (int count = 0; count < list.Count; count++)
  32. {
  33. if (list[count].Name == "AssetDatabaseABDataSource")
  34. properList[0] = list[count];
  35. else if (list[count] != null)
  36. properList.Add(list[count]);
  37. }
  38. }
  39. catch (System.Exception)
  40. {
  41. //assembly which raises exception on the GetTypes() call - ignore it
  42. }
  43. }
  44. return properList;
  45. }
  46. }
  47. }