暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ConversionIndexers.cs 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using UnityEditor.Search;
  2. using UnityEngine;
  3. using Object = UnityEngine.Object;
  4. namespace UnityEditor.Rendering.Universal
  5. {
  6. static class ConversionIndexers
  7. {
  8. private const int k_Version = 8;
  9. [CustomObjectIndexer(typeof(Object), version = k_Version)]
  10. internal static void ConversionIndexer(CustomObjectIndexerTarget context, ObjectIndexer indexer)
  11. {
  12. //Custom finding of all default Material properties on every single object type including custom types
  13. if (MaterialReferenceBuilder.MaterialReferenceLookup.TryGetValue(context.targetType, out var methods))
  14. {
  15. foreach (var method in methods)
  16. {
  17. if (method == null) continue;
  18. var result = method.GetMaterialFromMethod(context.target, (methodName, objectName) =>
  19. $"The method {methodName} was not found on {objectName}. This property will not be indexed.");
  20. if (result is Material materialResult)
  21. {
  22. if (materialResult != null && MaterialReferenceBuilder.GetIsReadonlyMaterial(materialResult))
  23. {
  24. indexer.AddProperty("urp", "convert-readonly", context.documentIndex);
  25. }
  26. }
  27. else if (result is Material[] materialArrayResult)
  28. {
  29. foreach (var material in materialArrayResult)
  30. {
  31. if (material != null && MaterialReferenceBuilder.GetIsReadonlyMaterial(material))
  32. {
  33. indexer.AddProperty("urp", "convert-readonly", context.documentIndex);
  34. }
  35. }
  36. }
  37. }
  38. }
  39. }
  40. }
  41. }