43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class WebPoint : MonoBehaviour
|
|
{
|
|
public bool ison;
|
|
public static WebPoint instance;
|
|
private RawImage rawImage;
|
|
Vector3 mousePosition;
|
|
float minX = 2000f;
|
|
float maxX = 5500f;
|
|
float minY = 550f;
|
|
float maxY = 2550f;
|
|
float targetResolutionX = 7680f;
|
|
float targetResolutionY = 3240f;
|
|
void Start()
|
|
{
|
|
instance = this;
|
|
rawImage = GetComponent<RawImage>();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
mousePosition = Input.mousePosition;
|
|
// 获取屏幕尺寸
|
|
float screenWidth = Screen.width;
|
|
float screenHeight = Screen.height;
|
|
|
|
if (mousePosition.x / screenWidth > minX / targetResolutionX && mousePosition.x / screenWidth < maxX / targetResolutionX
|
|
&& mousePosition.y / screenHeight > minY / targetResolutionY && mousePosition.y / screenHeight < maxY / targetResolutionY)
|
|
{
|
|
rawImage.raycastTarget = false;
|
|
}
|
|
else
|
|
{
|
|
rawImage.raycastTarget = true;
|
|
}
|
|
}
|
|
}
|