43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class AmpereMeter : MonoBehaviour
|
|
{
|
|
public Image im;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (Input.GetMouseButton(0))
|
|
{
|
|
//1.参数ray 为射线碰撞检测的光线(返回一个从相机到屏幕鼠标位置的光线)
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
RaycastHit hit;
|
|
if (Physics.Raycast(ray, out hit, 50) && !EventSystem.current.IsPointerOverGameObject()) //如果碰撞检测到物体
|
|
{
|
|
if (hit.collider.transform.tag.Equals("FuAn"))
|
|
{
|
|
Debug.Log(hit.collider.name);
|
|
if (im != null&& GameManager.ins.FuAnBiao!=null)
|
|
{
|
|
im.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
GameManager.ins.FuAnBiao = hit.collider.gameObject;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|