using System.Collections; using System.Collections.Generic; using UnityEngine; public class CheckCurrent_qianxing : MonoBehaviour { public Raycast_control_qianxing raycast_Control; public AudioSource audioSource; public Transform 交互点; public Transform 灯; 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()) { if (raycast_Control.hitgo.GetComponent().是否带电 == true) { audioSource.gameObject.SetActive(true); 灯.gameObject.SetActive(true); } 交互点.transform.localEulerAngles = raycast_Control.hitgo.transform.forward; 交互点.transform.position = raycast_Control.hitInfo.point; 交互点.GetComponent().enabled = true; } } else { audioSource.gameObject.SetActive(false); 灯.gameObject.SetActive(false); 交互点.transform.localEulerAngles = startrot; 交互点.transform.localPosition = startpos; 交互点.GetComponent().enabled = false; } } }