#if GRAPH_DESIGNER /// --------------------------------------------- /// Behavior Designer /// Copyright (c) Opsive. All Rights Reserved. /// https://www.opsive.com /// --------------------------------------------- namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.GameObjectTasks { using Opsive.GraphDesigner.Runtime.Variables; using UnityEngine; [Opsive.Shared.Utility.Category("GameObject")] [Opsive.Shared.Utility.Description("Enables or disables the specified component.")] public class SetEnabled : Action { [Tooltip("The component reference that should be enabled or disabled.")] [SerializeField] protected SharedVariable m_Component; [Tooltip("The behavior that should be enabled or disabled.")] [SerializeField] protected Behaviour m_Behavior; [Tooltip("Should the component be enabled?")] [SerializeField] protected SharedVariable m_Enable = true; /// /// Executes the action logic. /// /// The status of the action. public override TaskStatus OnUpdate() { var behaviour = m_Component?.GetValue() as Behaviour; if (behaviour != null) { behaviour.enabled = m_Enable.Value; } if (m_Behavior != null) { m_Behavior.enabled = m_Enable.Value; } return TaskStatus.Success; } /// /// Resets the action values back to their default. /// public override void Reset() { base.Reset(); m_Component = null; m_Behavior = null; m_Enable = true; } } } #endif