StackNodeViewProvider.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using UnityEditor;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. using UnityEngine;
  6. namespace GraphProcessor
  7. {
  8. public static class StackNodeViewProvider
  9. {
  10. static Dictionary< Type, Type > stackNodeViewPerType = new Dictionary< Type, Type >();
  11. static StackNodeViewProvider()
  12. {
  13. foreach (var t in TypeCache.GetTypesWithAttribute<CustomStackNodeView>())
  14. {
  15. var attr = t.GetCustomAttributes(false).Select(a => a as CustomStackNodeView).FirstOrDefault();
  16. stackNodeViewPerType.Add(attr.stackNodeType, t);
  17. // Debug.Log("Add " + attr.stackNodeType);
  18. }
  19. }
  20. public static Type GetStackNodeCustomViewType(Type stackNodeType)
  21. {
  22. // Debug.Log(stackNodeType);
  23. foreach (var t in stackNodeViewPerType)
  24. {
  25. // Debug.Log(t.Key + " -> " + t.Value);
  26. }
  27. stackNodeViewPerType.TryGetValue(stackNodeType, out var view);
  28. return view;
  29. }
  30. }
  31. }