53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class CheckCurrent : MonoBehaviour
|
|
{
|
|
public Raycast_control raycast_Control;
|
|
public AudioSource audioSource;
|
|
public Transform 验电笔;
|
|
public GameObject 使用中模型;
|
|
public GameObject 初始角度模型;
|
|
private Vector3 startrot;
|
|
private Vector3 startpos;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
startrot = 验电笔.transform.localEulerAngles;
|
|
startpos = 验电笔.transform.localPosition;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (raycast_Control.hitgo != null) {
|
|
|
|
|
|
if (raycast_Control.hitgo.GetComponent<CurrentJudgment>())
|
|
{
|
|
if (raycast_Control.hitgo.GetComponent<CurrentJudgment>().是否带电 == true)
|
|
{ audioSource.gameObject.SetActive(true); }
|
|
|
|
验电笔.transform.localEulerAngles = raycast_Control.hitgo.transform.forward;
|
|
验电笔.transform.position = raycast_Control.hitInfo.point;
|
|
验电笔.GetComponent<Collider>().enabled = true;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
|
|
audioSource.gameObject.SetActive(false);
|
|
|
|
验电笔.transform.localEulerAngles = startrot;
|
|
验电笔.transform.localPosition = startpos;
|
|
验电笔.GetComponent<Collider>().enabled = false;
|
|
}
|
|
}
|
|
}
|