using DG.Tweening; using System.Collections; using System.Collections.Generic; using UnityEngine; public class JunctionBox : MonoBehaviour { /// /// 透明盖 /// public Transform TransparentlidObj; ///// ///// 横向滑块 ///// //public Transform HorizontalSlider; ///// ///// 纵向滑块 ///// //public Transform VerticalSlider; /// /// 是否盖上 /// bool iscover; void Start() { } void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; bool raycast = Physics.Raycast(ray, out hit); if (raycast) { if (hit.collider.gameObject.name == "盖_透明外壳") { TransparentlidObj.transform.DOLocalMove(new Vector3(0, -0.0914f, 0),2f); ////判断盖子是否打开 } if (!iscover) { //iscover = true; switch (hit.collider.gameObject.name) { case "接线盒纵向滑块001": hit.collider.gameObject.transform.DOLocalMove(new Vector3(0.06131744f, -0.0075f, 0.0089f), 1f); Debug.Log(hit.collider.gameObject.name); break; case "接线盒纵向滑块002": hit.collider.gameObject.transform.DOLocalMove(new Vector3(0.02013969f, -0.0075f, 0.0089f), 1f); Debug.Log(hit.collider.gameObject.name); break; case "接线盒纵向滑块003": hit.collider.gameObject.transform.DOLocalMove(new Vector3(-0.02001452f, -0.0075f, 0.0089f), 1f); Debug.Log(hit.collider.gameObject.name); break; case "接线盒纵向滑块004": hit.collider.gameObject.transform.DOLocalMove(new Vector3(-0.06075525f, -0.0075f, 0.0089f), 1f); Debug.Log(hit.collider.gameObject.name); break; } } } } } }