blob: 535355fdcbcf3d9e9ccdd6e60e2f08369e220f81 (
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
|
using UnityEngine;
namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityBehaviour
{
[TaskCategory("Basic/Behaviour")]
[TaskDescription("Enables/Disables the object. Returns Success.")]
public class SetIsEnabled : Action
{
[Tooltip("The Object to use")]
public SharedObject specifiedObject;
[Tooltip("The enabled/disabled state")]
public SharedBool enabled;
public override TaskStatus OnUpdate()
{
if (specifiedObject == null && !(specifiedObject.Value is UnityEngine.Behaviour)) {
Debug.LogWarning("SpecifiedObject is null or not a subclass of UnityEngine.Behaviour");
return TaskStatus.Failure;
}
(specifiedObject.Value as Behaviour).enabled = enabled.Value;
return TaskStatus.Success;
}
public override void OnReset()
{
if (specifiedObject != null) {
specifiedObject.Value = null;
}
enabled = false;
}
}
}
|