IndieGame/client/Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/SystemEvents/CheckMouseClick2D.cs

45 lines
1.1 KiB
C#
Raw Permalink Normal View History

2024-10-11 10:12:15 +08:00
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Category("System Events")]
[Name("Check Mouse Click 2D")]
public class CheckMouseClick2D : ConditionTask<Collider2D>
{
public MouseClickEvent checkType = MouseClickEvent.MouseDown;
protected override string info {
get { return checkType.ToString(); }
}
protected override bool OnCheck() { return false; }
protected override void OnEnable() {
router.onMouseDown += OnMouseDown;
router.onMouseUp += OnMouseUp;
}
protected override void OnDisable() {
router.onMouseDown -= OnMouseDown;
router.onMouseUp -= OnMouseUp;
}
void OnMouseDown(ParadoxNotion.EventData msg) {
if ( checkType == MouseClickEvent.MouseDown ) {
YieldReturn(true);
}
}
void OnMouseUp(ParadoxNotion.EventData msg) {
if ( checkType == MouseClickEvent.MouseUp ) {
YieldReturn(true);
}
}
}
}