using System.Collections; using System.Collections.Generic; using UnityEngine; //============================================================ //支持中文,文件使用UTF-8编码 //@author #AUTHOR# //@create #CREATEDATE# //@company #COMPANY# // //@description:管理所有生成的设备 //============================================================ public class DeviceManager : MonoBehaviour { public List deviceItems = new List(); 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); } }