1
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>炮台控制模式</summary>
|
||||
@@ -14,8 +15,18 @@ public enum TurretControlMode
|
||||
XJMH = 1
|
||||
}
|
||||
|
||||
public class SitPosData : MonoBehaviour
|
||||
public class SitPosData : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
|
||||
{
|
||||
[Tooltip("长按判定时间(秒):按住 img_OpenPT 超过此时间触发 OnOpenPTLongPress")]
|
||||
public float openPTLongPressTime = 0.5f;
|
||||
public Image img_OpenPT;
|
||||
|
||||
/// <summary>长按 img_OpenPT 触发一次(GameMainPanel 订阅后用它开关炮台面板,仅本地玩家座位有意义)</summary>
|
||||
public event Action OnOpenPTLongPress;
|
||||
|
||||
private bool _openPTPressing;
|
||||
private float _openPTPressTimer;
|
||||
|
||||
public bool IsBaoJiangingActive;
|
||||
public Transform obj_BaoJiangZhongPanelPosition;
|
||||
|
||||
@@ -294,6 +305,39 @@ public class SitPosData : MonoBehaviour
|
||||
private void Update()
|
||||
{
|
||||
UpdateZhanShenLaser();
|
||||
|
||||
// ⭐ 长按 img_OpenPT 计时:到达阈值触发一次(提前松手不触发)
|
||||
if (_openPTPressing)
|
||||
{
|
||||
_openPTPressTimer += Time.deltaTime;
|
||||
if (_openPTPressTimer >= openPTLongPressTime)
|
||||
{
|
||||
_openPTPressing = false;
|
||||
_openPTPressTimer = 0f;
|
||||
OnOpenPTLongPress?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 长按 img_OpenPT(打开炮台面板) ====================
|
||||
|
||||
/// <summary>按下:命中 img_OpenPT(或其子对象)才开始长按计时(其他区域不响应)</summary>
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
if (img_OpenPT == null) return;
|
||||
var hit = eventData.pointerCurrentRaycast.gameObject;
|
||||
if (hit == null) return;
|
||||
if (hit != img_OpenPT.gameObject && !hit.transform.IsChildOf(img_OpenPT.transform)) return;
|
||||
|
||||
_openPTPressing = true;
|
||||
_openPTPressTimer = 0f;
|
||||
}
|
||||
|
||||
/// <summary>松开:取消长按计时(未达阈值不触发)</summary>
|
||||
public void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
_openPTPressing = false;
|
||||
_openPTPressTimer = 0f;
|
||||
}
|
||||
|
||||
// ==================== 战神激光(锁定时显示) ====================
|
||||
|
||||
Reference in New Issue
Block a user