NotNode.cs 626 B

12345678910111213141516171819202122232425
  1. using System.Linq;
  2. using UnityEngine;
  3. namespace XNode.Examples.LogicToy {
  4. [NodeWidth(140), NodeTint(100, 100, 50)]
  5. public class NotNode : LogicNode {
  6. [Input, HideInInspector] public bool input;
  7. [Output, HideInInspector] public bool output = true;
  8. public override bool led { get { return output; } }
  9. protected override void OnInputChanged() {
  10. bool newInput = GetPort("input").GetInputValues<bool>().Any(x => x);
  11. if (input != newInput) {
  12. input = newInput;
  13. output = !newInput;
  14. SendSignal(GetPort("output"));
  15. }
  16. }
  17. public override object GetValue(NodePort port) {
  18. return output;
  19. }
  20. }
  21. }