summaryrefslogtreecommitdiff
path: root/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetLength.cs
blob: 5c41ff2ba6ee39d16bea7b98427dcf2a21a6d1a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using UnityEngine;

namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityString
{
    [TaskCategory("Basic/String")]
    [TaskDescription("Stores the length of the string")]
    public class GetLength : Action
    {
        [Tooltip("The target string")]
        public SharedString targetString;
        [Tooltip("The stored result")]
        [RequiredField]
        public SharedInt storeResult;

        public override TaskStatus OnUpdate()
        {
            storeResult.Value = targetString.Value.Length;
            return TaskStatus.Success;
        }

        public override void OnReset()
        {
            targetString = "";
            storeResult = 0;
        }
    }
}