GetLength.cs 669 B

12345678910111213141516171819202122232425
  1. namespace BehaviorDesigner.Runtime.Tasks.Unity.UnityString
  2. {
  3. [TaskCategory("Unity/String")]
  4. [TaskDescription("Stores the length of the string")]
  5. public class GetLength : Action
  6. {
  7. [Tooltip("The target string")]
  8. public SharedString targetString;
  9. [Tooltip("The stored result")]
  10. [RequiredField]
  11. public SharedInt storeResult;
  12. public override TaskStatus OnUpdate()
  13. {
  14. storeResult.Value = targetString.Value.Length;
  15. return TaskStatus.Success;
  16. }
  17. public override void OnReset()
  18. {
  19. targetString = "";
  20. storeResult = 0;
  21. }
  22. }
  23. }