No Description
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.

ScriptMachine.cs 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using UnityEngine;
  2. namespace Unity.VisualScripting
  3. {
  4. [AddComponentMenu("Visual Scripting/Script Machine")]
  5. [RequireComponent(typeof(Variables))]
  6. [DisableAnnotation]
  7. [HelpURL("https://docs.unity3d.com/Packages/com.unity.visualscripting@latest/index.html?subfolder=/manual/vs-graphs-machines-macros.html")]
  8. [RenamedFrom("Bolt.FlowMachine")]
  9. [RenamedFrom("Unity.VisualScripting.FlowMachine")]
  10. public sealed class ScriptMachine : EventMachine<FlowGraph, ScriptGraphAsset>
  11. {
  12. public override FlowGraph DefaultGraph()
  13. {
  14. return FlowGraph.WithStartUpdate();
  15. }
  16. protected override void OnEnable()
  17. {
  18. if (hasGraph)
  19. {
  20. graph.StartListening(reference);
  21. }
  22. base.OnEnable();
  23. }
  24. protected override void OnInstantiateWhileEnabled()
  25. {
  26. if (hasGraph)
  27. {
  28. graph.StartListening(reference);
  29. }
  30. base.OnInstantiateWhileEnabled();
  31. }
  32. protected override void OnUninstantiateWhileEnabled()
  33. {
  34. base.OnUninstantiateWhileEnabled();
  35. if (hasGraph)
  36. {
  37. graph.StopListening(reference);
  38. }
  39. }
  40. protected override void OnDisable()
  41. {
  42. base.OnDisable();
  43. if (hasGraph)
  44. {
  45. graph.StopListening(reference);
  46. }
  47. }
  48. [ContextMenu("Show Data...")]
  49. protected override void ShowData()
  50. {
  51. base.ShowData();
  52. }
  53. }
  54. }