|
|
@@ -41,27 +41,50 @@ public class PointMarker : MonoBehaviour
|
|
|
{
|
|
|
if (AimHandler.ins) AimHandler.ins.OnCrossBtnEvent -= OnRecordInfrared;
|
|
|
}
|
|
|
-
|
|
|
+ private float lastClickTime = 0f;
|
|
|
+ private float doubleClickThreshold = 0.3f; // 双击间隔时间,单位:秒
|
|
|
void Update()
|
|
|
{
|
|
|
-//#if UNITY_EDITOR
|
|
|
- if (Input.GetKeyDown(KeyCode.Alpha6) || Input.GetMouseButtonDown(1))
|
|
|
+ if (Input.GetMouseButtonDown(0)) // 检测左键按下
|
|
|
{
|
|
|
- //Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
|
|
- //MarkPoint(mousePosition);
|
|
|
- // OnRecordInfrared();
|
|
|
- if (currentPointIndex >= 4) return;
|
|
|
- var mouse = Input.mousePosition;
|
|
|
- var u = mouse.x / Screen.width;
|
|
|
- var v = mouse.y / Screen.height;
|
|
|
- u = Math.Clamp(u, 0, 1);
|
|
|
- v = Math.Clamp(v, 0, 1);
|
|
|
- Vector2 pos = new Vector2(u * ScreenLocate.Main.getUVCTexture.width, v * ScreenLocate.Main.getUVCTexture.height);
|
|
|
- markedPoints.Add(pos);
|
|
|
- // 设置标记的位置
|
|
|
- MarkPoint(new Vector2(u, v).pixelToLocalPosition_AnchorCenter(new Vector2(1, 1), markerParent.GetComponent<RectTransform>().rect));
|
|
|
+ float currentTime = Time.time;
|
|
|
+ if (currentTime - lastClickTime <= doubleClickThreshold)
|
|
|
+ {
|
|
|
+ // 双击检测成功,执行触发逻辑
|
|
|
+ if (currentPointIndex >= 4) return;
|
|
|
+
|
|
|
+ var mouse = Input.mousePosition;
|
|
|
+ var u = mouse.x / Screen.width;
|
|
|
+ var v = mouse.y / Screen.height;
|
|
|
+ u = Math.Clamp(u, 0, 1);
|
|
|
+ v = Math.Clamp(v, 0, 1);
|
|
|
+
|
|
|
+ Vector2 pos = new Vector2(u * ScreenLocate.Main.getUVCTexture.width, v * ScreenLocate.Main.getUVCTexture.height);
|
|
|
+ markedPoints.Add(pos);
|
|
|
+
|
|
|
+ // 设置标记的位置
|
|
|
+ MarkPoint(new Vector2(u, v).pixelToLocalPosition_AnchorCenter(new Vector2(1, 1), markerParent.GetComponent<RectTransform>().rect));
|
|
|
+ }
|
|
|
+ lastClickTime = currentTime; // 更新上一次点击时间
|
|
|
}
|
|
|
-//#endif
|
|
|
+ //#if UNITY_EDITOR
|
|
|
+ //if (Input.GetKeyDown(KeyCode.Alpha6) || Input.GetMouseButtonDown(1))
|
|
|
+ //{
|
|
|
+ // //Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
|
|
+ // //MarkPoint(mousePosition);
|
|
|
+ // // OnRecordInfrared();
|
|
|
+ // if (currentPointIndex >= 4) return;
|
|
|
+ // var mouse = Input.mousePosition;
|
|
|
+ // var u = mouse.x / Screen.width;
|
|
|
+ // var v = mouse.y / Screen.height;
|
|
|
+ // u = Math.Clamp(u, 0, 1);
|
|
|
+ // v = Math.Clamp(v, 0, 1);
|
|
|
+ // Vector2 pos = new Vector2(u * ScreenLocate.Main.getUVCTexture.width, v * ScreenLocate.Main.getUVCTexture.height);
|
|
|
+ // markedPoints.Add(pos);
|
|
|
+ // // 设置标记的位置
|
|
|
+ // MarkPoint(new Vector2(u, v).pixelToLocalPosition_AnchorCenter(new Vector2(1, 1), markerParent.GetComponent<RectTransform>().rect));
|
|
|
+ //}
|
|
|
+ //#endif
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 记录红外点
|