42 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			42 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;
 | 
						|
    public Camera cam;
 | 
						|
    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 (hit.collider.transform.tag.Equals("FuAnBiao"))
 | 
						|
                {
 | 
						|
                    if (GlobalFlag.sceneData.info0 != "单相")
 | 
						|
                    {
 | 
						|
                        if (im != null && GameManager.Instance.FuAnBiao != null)
 | 
						|
                        {
 | 
						|
                            im.gameObject.SetActive(true);
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |