EnterStateNode.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using XNode;
  5. using System;
  6. using Sirenix.OdinInspector;
  7. using System.Linq;
  8. namespace ChivaVR.State
  9. {
  10. /// <summary>
  11. /// 流程进入
  12. /// </summary>
  13. public class EnterStateNode : StateNode
  14. {
  15. [Output] public Empty exit;
  16. public override void OnEnter()
  17. {
  18. base.OnEnter();
  19. OnExit();
  20. }
  21. public override void OnExit()
  22. {
  23. base.OnExit();
  24. NodePort exitPort = GetOutputPort("exit");
  25. if (!exitPort.IsConnected)
  26. {
  27. Debug.LogWarning("Node isn't connected");
  28. return;
  29. }
  30. for (int i = 0; i < exitPort.GetConnections().Count; i++)
  31. {
  32. StateNode connectEnterNode = exitPort.GetConnection(i).node as StateNode;
  33. if (connectEnterNode.CheckEnterConnectState())
  34. {
  35. connectEnterNode.OnEnter();
  36. }
  37. }
  38. }
  39. }
  40. }