blob: 6ede171f77a00df2b0b718160324b7c7cd6de03d (
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
33
34
35
|
namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityString
{
[TaskCategory("Basic/String")]
[TaskDescription("Stores a substring of the target string")]
public class GetSubstring : Action
{
[Tooltip("The target string")]
public SharedString targetString;
[Tooltip("The start substring index")]
public SharedInt startIndex = 0;
[Tooltip("The length of the substring. Don't use if -1")]
public SharedInt length = -1;
[Tooltip("The stored result")]
[RequiredField]
public SharedString storeResult;
public override TaskStatus OnUpdate()
{
if (length.Value != -1) {
storeResult.Value = targetString.Value.Substring(startIndex.Value, length.Value);
} else {
storeResult.Value = targetString.Value.Substring(startIndex.Value);
}
return TaskStatus.Success;
}
public override void OnReset()
{
targetString = "";
startIndex = 0;
length = -1;
storeResult = "";
}
}
}
|