Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

KeywordCollection.cs 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace UnityEditor.ShaderGraph
  4. {
  5. [GenerationAPI]
  6. internal class KeywordCollection : IEnumerable<KeywordCollection.Item>
  7. {
  8. public class Item : IConditional
  9. {
  10. public KeywordDescriptor descriptor { get; }
  11. public FieldCondition[] fieldConditions { get; }
  12. public Item(KeywordDescriptor descriptor, FieldCondition[] fieldConditions)
  13. {
  14. this.descriptor = descriptor;
  15. this.fieldConditions = fieldConditions;
  16. }
  17. }
  18. readonly List<Item> m_Items;
  19. public KeywordCollection()
  20. {
  21. m_Items = new List<Item>();
  22. }
  23. public KeywordCollection Add(KeywordCollection keywords)
  24. {
  25. foreach (KeywordCollection.Item item in keywords)
  26. {
  27. m_Items.Add(item);
  28. }
  29. return this;
  30. }
  31. public KeywordCollection Add(KeywordDescriptor descriptor)
  32. {
  33. m_Items.Add(new Item(descriptor, null));
  34. return this;
  35. }
  36. public KeywordCollection Add(KeywordDescriptor descriptor, FieldCondition fieldCondition)
  37. {
  38. m_Items.Add(new Item(descriptor, new FieldCondition[] { fieldCondition }));
  39. return this;
  40. }
  41. public KeywordCollection Add(KeywordDescriptor descriptor, FieldCondition[] fieldConditions)
  42. {
  43. m_Items.Add(new Item(descriptor, fieldConditions));
  44. return this;
  45. }
  46. public IEnumerator<Item> GetEnumerator()
  47. {
  48. return m_Items.GetEnumerator();
  49. }
  50. IEnumerator IEnumerable.GetEnumerator()
  51. {
  52. return GetEnumerator();
  53. }
  54. }
  55. }