CompareTo.cs 933 B

12345678910111213141516171819202122232425262728
  1. namespace BehaviorDesigner.Runtime.Tasks.Unity.UnityString
  2. {
  3. [TaskCategory("Unity/String")]
  4. [TaskDescription("Compares the first string to the second string. Returns an int which indicates whether the first string precedes, matches, or follows the second string.")]
  5. public class CompareTo : Action
  6. {
  7. [Tooltip("The string to compare")]
  8. public SharedString firstString;
  9. [Tooltip("The string to compare to")]
  10. public SharedString secondString;
  11. [Tooltip("The stored result")]
  12. [RequiredField]
  13. public SharedInt storeResult;
  14. public override TaskStatus OnUpdate()
  15. {
  16. storeResult.Value = firstString.Value.CompareTo(secondString.Value);
  17. return TaskStatus.Success;
  18. }
  19. public override void OnReset()
  20. {
  21. firstString = "";
  22. secondString = "";
  23. storeResult = 0;
  24. }
  25. }
  26. }