GQ_Communicate/GQ_TongXin/Assets/Adam/Scripts/DeviceManager.cs

63 lines
2.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
// Use this for initialization
private void Start()
{
editorMenu.gameObject.SetActive(false);
SwitchStagingPanel();
}
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();
editorMenu.saveBtn.onClick.AddListener(() =>
{
DragController dc = Instantiate(dragController, dragControllerContent);
dc.oriObjectPrefab = dtPrefab;
dc.isSaveMode = true;
uposManger.SetCurrentUPosIsOccupied(di.startIndex, di.volume, false);
Destroy(di.gameObject);
editorMenu.gameObject.SetActive(false);
SwitchStagingPanel();
});
}
public void SwitchStagingPanel()
{
Debug.Log("dragControllerContent.childCount=="+ dragControllerContent.childCount);
if (dragControllerContent.childCount > 0)
stagingPanel.SetActive(true);
else if (dragControllerContent.childCount == 0)
stagingPanel.SetActive(false);
}
}