SetSharedGameObject.cs 1.0 KB

1234567891011121314151617181920212223242526272829
  1. namespace BehaviorDesigner.Runtime.Tasks.Unity.SharedVariables
  2. {
  3. [TaskCategory("Unity/SharedVariable")]
  4. [TaskDescription("Sets the SharedGameObject variable to the specified object. Returns Success.")]
  5. public class SetSharedGameObject : Action
  6. {
  7. [Tooltip("The value to set the SharedGameObject to. If null the variable will be set to the current GameObject")]
  8. public SharedGameObject targetValue;
  9. [RequiredField]
  10. [Tooltip("The SharedGameObject to set")]
  11. public SharedGameObject targetVariable;
  12. [Tooltip("Can the target value be null?")]
  13. public SharedBool valueCanBeNull;
  14. public override TaskStatus OnUpdate()
  15. {
  16. targetVariable.Value = ((targetValue.Value != null || valueCanBeNull.Value) ? targetValue.Value : gameObject);
  17. return TaskStatus.Success;
  18. }
  19. public override void OnReset()
  20. {
  21. valueCanBeNull = false;
  22. targetValue = null;
  23. targetVariable = null;
  24. }
  25. }
  26. }