浮标点和相机停靠点外置,用resources加载图片,删除脚本文件夹分类
This commit is contained in:
44
Assets/Scripts/MouseSuspensionOneSecond.cs
Normal file
44
Assets/Scripts/MouseSuspensionOneSecond.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MouseSuspensionOneSecond : MonoBehaviour
|
||||
{
|
||||
Camera cam;
|
||||
private float hoverTime = 0f;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
cam = Camera.main;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
|
||||
|
||||
if(Physics.Raycast(ray,out RaycastHit hit))
|
||||
{
|
||||
if (Vector3.Distance(cam.transform.position, hit.transform.position) < 8f && hit.collider.CompareTag("Target") )
|
||||
{
|
||||
hoverTime += Time.deltaTime;
|
||||
if (hoverTime >= 0.6f)
|
||||
{
|
||||
//Debug.Log("dianzhong");
|
||||
UIManager.Instance.DisplayData(hit.collider.gameObject.name);
|
||||
hoverTime = -999f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hoverTime = 0f;
|
||||
UIManager.Instance.HideData();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hoverTime = 0f;
|
||||
UIManager.Instance.HideData();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user