46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class AmpereMeter : MonoBehaviour
|
|
{
|
|
public Image im;
|
|
int sum = 0;
|
|
// 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 (sum != 0)
|
|
//{
|
|
// if (hit.collider.CompareTag("FuAn"))
|
|
// {
|
|
// im.gameObject.SetActive(true);
|
|
// }
|
|
//}
|
|
if (hit.collider.transform.tag.Equals("FuAnBiao"))
|
|
{
|
|
Debug.Log(hit.collider.name);
|
|
if (im != null && GameManager.ins.FuAnBiao != null)
|
|
{
|
|
sum++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|