CompareLayer.cs 819 B

123456789101112131415161718192021222324
  1. using UnityEngine;
  2. namespace BehaviorDesigner.Runtime.Tasks.Unity.UnityGameObject
  3. {
  4. [TaskCategory("Unity/GameObject")]
  5. [TaskDescription("Returns Success if the layermasks match, otherwise Failure.")]
  6. public class CompareLayerMask : Conditional
  7. {
  8. [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")]
  9. public SharedGameObject targetGameObject;
  10. [Tooltip("The layermask to compare against")]
  11. public LayerMask layermask;
  12. public override TaskStatus OnUpdate()
  13. {
  14. return ((1 << GetDefaultGameObject(targetGameObject.Value).layer) & layermask.value) != 0 ? TaskStatus.Success : TaskStatus.Failure;
  15. }
  16. public override void OnReset()
  17. {
  18. targetGameObject = null;
  19. }
  20. }
  21. }