| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- 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<PartLabelPanel>();
- }
- private void Start()
- {
- DeviceOfPartDataProxy deviceOfPartDataProxy = DAL.Instance.Get<DeviceOfPartDataProxy>();
- deviceOfPartDataProxy.ReadStepMsgInfoFromTable(DeviceName);
- PartInfo tmpPartInfo = GetDevicePartInfos(transform.GetComponent<PartMark>());
- UIKit.OpenPanel<PartListPanel>(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<PartMark>() != null)
- {
- PartMark tmpMark = hit.collider.GetComponentInParent<PartMark>();
-
- if (tmpMark != null)
- {
- UIKit.OpenPanel<PartLabelPanel>(UILevel.PopUI,new PartLabelPanelData() { partName = tmpMark.name });
- }
- }
- }
- else
- {
- UIKit.HidePanel<PartLabelPanel>();
- }
- if (Input.GetMouseButtonDown(0))
- {
- Ray ray1 = Camera.main.ScreenPointToRay(Input.mousePosition);
- RaycastHit hit1;
- if (Physics.Raycast(ray1, out hit1))
- {
- PartMark tmpMark = hit.collider.GetComponentInParent<PartMark>();
- if (tmpMark != null)
- {
- tmpMark.SetState(false);
- UIKit.GetPanel<PartListPanel>().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;
- }
- }
|