summaryrefslogtreecommitdiff
path: root/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/Replace.cs
blob: 869df7a52aef4c5d7a79e104095eee79366d4395 (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
28
29
30
31
32
namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityString
{
    [TaskCategory("Basic/String")]
    [TaskDescription("Replaces a string with the new string")]
    public class Replace : Action
    {
        [Tooltip("The target string")]
        public SharedString targetString;
        [Tooltip("The old replace")]
        public SharedString oldString;
        [Tooltip("The new string")]
        public SharedString newString;
        [Tooltip("The stored result")]
        [RequiredField]
        public SharedString storeResult;

        public override TaskStatus OnUpdate()
        {
            storeResult.Value = targetString.Value.Replace(oldString.Value, newString.Value);

            return TaskStatus.Success;
        }

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