MessageNode.cs 635 B

123456789101112131415161718192021222324252627
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using GraphProcessor;
  5. using System.Linq;
  6. [System.Serializable, NodeMenuItem("Custom/MessageNode")]
  7. public class MessageNode : BaseNode
  8. {
  9. const string k_InputIsNot42Error = "Input is not 42 !";
  10. [Input(name = "In")]
  11. public float input;
  12. public override string name => "MessageNode";
  13. [Setting("Message Type")]
  14. public NodeMessageType messageType = NodeMessageType.Error;
  15. protected override void Process()
  16. {
  17. if (input != 42)
  18. AddMessage(k_InputIsNot42Error, messageType);
  19. else
  20. RemoveMessage(k_InputIsNot42Error);
  21. }
  22. }