-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathSetGameObjectOtherTree.cs
39 lines (32 loc) · 1.06 KB
/
SetGameObjectOtherTree.cs
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
36
37
38
39
using UnityEngine;
using System.Collections;
namespace BehaviorDesigner.Runtime.Tasks.Custom
{
[TaskDescription("Sets a game object var on another tree defined by sharedGameObject")]
public class SetGameObjectOtherTree : Action
{
public SharedGameObject sharedGameObject;
public string variableName;
public SharedGameObject targetVariable;
private BehaviorTree behaviorTree;
public override void OnStart()
{
behaviorTree = sharedGameObject.Value.GetComponent<BehaviorTree>();
}
public override TaskStatus OnUpdate()
{
if (behaviorTree == null)
{
return TaskStatus.Failure;
}
(behaviorTree.GetVariable(variableName) as SharedGameObject).Value = targetVariable.Value;
return TaskStatus.Success;
}
public override void OnReset()
{
behaviorTree = null;
variableName = "";
targetVariable = null;
}
}
}