92 lines
2.8 KiB
C#
92 lines
2.8 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
//============================================================
|
||
//支持中文,文件使用UTF-8编码
|
||
//@author #AUTHOR#
|
||
//@create #CREATEDATE#
|
||
//@company #COMPANY#
|
||
//
|
||
//@description:管理所有生成的设备
|
||
//============================================================
|
||
|
||
public class DeviceManager : MonoBehaviour
|
||
{
|
||
public List<DeviceItem> deviceItems = new List<DeviceItem>();
|
||
public EditorMenu editorMenu;
|
||
public RectTransform canvasRect;
|
||
public DragController dragController;
|
||
public Transform dragControllerContent;
|
||
public UPosManger uposManger;
|
||
public GameObject stagingPanel;
|
||
|
||
public Transform stagingParent;
|
||
// Use this for initialization
|
||
|
||
|
||
|
||
private void Start()
|
||
{
|
||
editorMenu.gameObject.SetActive(false);
|
||
SwitchStagingPanel(null);
|
||
}
|
||
|
||
public void SetDeviceItem(DeviceItem deviceItem)
|
||
{
|
||
deviceItems.Add(deviceItem);
|
||
}
|
||
|
||
public void SetMenuValue(Vector3 pos, DeviceItem di, DragTest1 dtPrefab)
|
||
{
|
||
editorMenu.gameObject.SetActive(true);
|
||
Vector2 uiLocalPos;
|
||
RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRect, pos, null, out uiLocalPos);
|
||
editorMenu.transform.localPosition = uiLocalPos;
|
||
editorMenu.saveBtn.onClick.RemoveAllListeners();
|
||
//SwitchHighLight(di);
|
||
editorMenu.saveBtn.onClick.AddListener(() =>
|
||
{
|
||
DragController dc = Instantiate(dragController, dragControllerContent);
|
||
dc.oriObjectPrefab = di.GetComponent<DragTest1>();
|
||
dc.isSaveMode = true;
|
||
uposManger.SetCurrentUPosIsOccupied(di.startIndex, di.volume, false);
|
||
//Destroy(di.gameObject);
|
||
|
||
di.transform.SetParent(stagingParent);
|
||
di.transform.localPosition = Vector3.zero;
|
||
di.gameObject.SetActive(false);
|
||
deviceItems.Remove(di);
|
||
|
||
editorMenu.gameObject.SetActive(false);
|
||
SwitchStagingPanel(null);
|
||
});
|
||
}
|
||
|
||
public void SwitchHighLight(DeviceItem di)
|
||
{
|
||
for (int i = 0; i < deviceItems.Count; i++)
|
||
{
|
||
deviceItems[i].GetComponent<HighLight_VR>().ShutDownHighlight();
|
||
}
|
||
di.GetComponent<HighLight_VR>().Highlight();
|
||
}
|
||
|
||
public void SwitchStagingPanel(GameObject staginDragClone)
|
||
{
|
||
if (staginDragClone != null)
|
||
Destroy(staginDragClone);
|
||
StopAllCoroutines();
|
||
StartCoroutine(WaitCloseStaginPanel());
|
||
}
|
||
|
||
private IEnumerator WaitCloseStaginPanel()
|
||
{
|
||
yield return new WaitForSeconds(0.1f);
|
||
Debug.Log("dragControllerContent.childCount==" + dragControllerContent.childCount);
|
||
if (dragControllerContent.childCount > 0)
|
||
stagingPanel.SetActive(true);
|
||
else
|
||
stagingPanel.SetActive(false);
|
||
}
|
||
}
|