using System.Collections; using System.Collections.Generic; using UnityEngine; using QFramework; public class DeviceController : MonoBehaviour { public static DeviceController instance; public string DeviceName; private void Awake() { instance = this; ResKit.Init(); UIKit.OpenPanel(); } private void Start() { DeviceOfPartDataProxy deviceOfPartDataProxy = DAL.Instance.Get(); deviceOfPartDataProxy.ReadStepMsgInfoFromTable(DeviceName); PartInfo tmpPartInfo = GetDevicePartInfos(transform.GetComponent()); UIKit.OpenPanel(new PartListPanelData() { m_PartInfo = tmpPartInfo}); CameraSurround.instance.SetCameraPosition(true); } private void Update() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { // 处理射线击中的对象 if (hit.collider.GetComponent() != null) { PartMark tmpMark = hit.collider.GetComponentInParent(); if (tmpMark != null) { UIKit.OpenPanel(UILevel.PopUI,new PartLabelPanelData() { partName = tmpMark.name }); } } } else { UIKit.HidePanel(); } if (Input.GetMouseButtonDown(0)) { Ray ray1 = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit1; if (Physics.Raycast(ray1, out hit1)) { PartMark tmpMark = hit.collider.GetComponentInParent(); if (tmpMark != null) { tmpMark.SetState(false); UIKit.GetPanel().SetPartItemState(tmpMark); } } } } public PartInfo GetDevicePartInfos(PartMark partMark) { //最父级 PartInfo partInfo = new PartInfo(partMark.transform.name,partMark); //字级 foreach (var item in partMark.m_ChildPartMarks) { partInfo.childPartInfos.Add(GetDevicePartInfos(item)); } return partInfo; } }