You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.4 KiB
47 lines
1.4 KiB
using AX.InputSystem; |
|
using AX.MessageSystem; |
|
using UnityEngine; |
|
using UnityEngine.EventSystems; |
|
|
|
[RequireComponent(typeof(BaseGameObjInfo))] |
|
[RequireComponent(typeof(CreateStaticObjID))] |
|
public class PointerClickBase : MonoBehaviour,IPointerClickHandler |
|
{ |
|
//点击委托 |
|
public delegate void PointerClickHandler(); |
|
//点击事件 |
|
public event PointerClickHandler OnRightClick; |
|
public void OnPointerClick(PointerEventData eventData) |
|
{ |
|
switch (eventData.button) |
|
{ |
|
case PointerEventData.InputButton.Left: |
|
break; |
|
case PointerEventData.InputButton.Right: |
|
var arg = new CmdArgs(); |
|
arg.currentCursorPos = Input.mousePosition; |
|
RegisterUIInputEvent.RegisterUIInputHistory(gameObject, this.GetType().Name, "rightClick", arg); |
|
if (OnRightClick!=null) |
|
{ |
|
OnRightClick(); |
|
} |
|
break; |
|
case PointerEventData.InputButton.Middle: |
|
break; |
|
} |
|
} |
|
private void rightClick(CmdArgs arg) |
|
{ |
|
if (GameSettings.othersSettings.playState != PlayState.None) |
|
{ |
|
if (GameSettings.othersSettings.playState == PlayState.Playing) |
|
{ |
|
CursorManager.GetInstance.SetClick(arg); |
|
} |
|
} |
|
if (OnRightClick!=null) |
|
{ |
|
OnRightClick(); |
|
} |
|
} |
|
} |