#if GRAPH_DESIGNER /// --------------------------------------------- /// Behavior Designer /// Copyright (c) Opsive. All Rights Reserved. /// https://www.opsive.com /// --------------------------------------------- namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Conversions { using Opsive.GraphDesigner.Runtime.Variables; using UnityEngine; [Opsive.Shared.Utility.Category("Conversions")] [Opsive.Shared.Utility.Description("Gets the GameObject from a Component.")] public class ConvertComponentToGameObject : Action { [Tooltip("The Component to get the GameObject from.")] [SerializeField] protected SharedVariable m_SourceComponent; [Tooltip("The resulting GameObject.")] [SerializeField] [RequireShared] protected SharedVariable m_ResultGameObject; /// /// Gets the GameObject from the Component. /// /// The status of the action. public override TaskStatus OnUpdate() { if (m_SourceComponent.Value == null) { m_ResultGameObject.Value = null; return TaskStatus.Success; } m_ResultGameObject.Value = m_SourceComponent.Value.gameObject; return TaskStatus.Success; } /// /// Resets the action values back to their default. /// public override void Reset() { base.Reset(); m_SourceComponent = null; m_ResultGameObject = null; } } } #endif