Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System.Collections.Generic;
  2. using UnityObject = UnityEngine.Object;
  3. namespace Unity.VisualScripting
  4. {
  5. [SpecialUnit]
  6. public abstract class NesterUnit<TGraph, TMacro> : Unit, INesterUnit
  7. where TGraph : class, IGraph, new()
  8. where TMacro : Macro<TGraph>
  9. {
  10. protected NesterUnit()
  11. {
  12. nest.nester = this;
  13. }
  14. protected NesterUnit(TMacro macro)
  15. {
  16. nest.nester = this;
  17. nest.macro = macro;
  18. nest.source = GraphSource.Macro;
  19. }
  20. public override bool canDefine => nest.graph != null;
  21. [Serialize]
  22. public GraphNest<TGraph, TMacro> nest { get; private set; } = new GraphNest<TGraph, TMacro>();
  23. [DoNotSerialize]
  24. IGraphNest IGraphNester.nest => nest;
  25. [DoNotSerialize]
  26. IGraph IGraphParent.childGraph => nest.graph;
  27. [DoNotSerialize]
  28. bool IGraphParent.isSerializationRoot => nest.source == GraphSource.Macro;
  29. [DoNotSerialize]
  30. UnityObject IGraphParent.serializedObject => nest.macro;
  31. [DoNotSerialize]
  32. public override IEnumerable<ISerializationDependency> deserializationDependencies => nest.deserializationDependencies;
  33. public override IEnumerable<object> GetAotStubs(HashSet<object> visited)
  34. {
  35. return LinqUtility.Concat<object>(base.GetAotStubs(visited), nest.GetAotStubs(visited));
  36. }
  37. protected void CopyFrom(NesterUnit<TGraph, TMacro> source)
  38. {
  39. base.CopyFrom(source);
  40. nest = source.nest;
  41. }
  42. public abstract TGraph DefaultGraph();
  43. IGraph IGraphParent.DefaultGraph() => DefaultGraph();
  44. void IGraphNester.InstantiateNest() => InstantiateNest();
  45. void IGraphNester.UninstantiateNest() => UninstantiateNest();
  46. }
  47. }