Editor模块

在节点中声明gameobject为this

Visual Scripting的API分析 - 图1

  1. public class AIShootEventNode : Unit
  2. {
  3. [DoNotSerialize]
  4. [PortLabelHidden]
  5. public ControlInput InputTrigger { get; private set; }
  6. [DoNotSerialize]
  7. [NullMeansSelf]
  8. [PortLabel("Target")]
  9. [PortLabelHidden]
  10. public ValueInput Target;
  11. [DoNotSerialize]
  12. public ValueInput ShootTarget;
  13. protected override void Definition()
  14. {
  15. InputTrigger = ControlInput(nameof(InputTrigger), Trigger);
  16. //在节点中声明gameobject为this
  17. Target = ValueInput<GameObject>(nameof(Target), null).NullMeansSelf();
  18. ShootTarget = ValueInput<RoundState>(nameof(ShootTarget), RoundState.Deler);
  19. }
  20. private ControlOutput Trigger(Flow flow)
  21. {
  22. EventBus.Trigger(MachineEventNames.AIUsePropEvent, flow.GetValue<GameObject>(Target), flow.GetValue<RoundState>(ShootTarget));
  23. return null;
  24. }
  25. }

特性

PortLabel:修改端口的显示文本

Visual Scripting的API分析 - 图2

  1. [DoNotSerialize]
  2. [PortLabel("实弹")]
  3. public ControlOutput BulletIsLive;

Runtime模块

运行时替换ScriptMachine.asset

  1. scriptMachine = gameObject.AddComponent<ScriptMachine>();
  2. scriptMachine.nest.SwitchToMacro(yourGraph);