diff --git a/GQ_TongXin/Assets/Adam/Scripts/DeviceManager.cs b/GQ_TongXin/Assets/Adam/Scripts/DeviceManager.cs index ccfe07ea5..e52a09f86 100644 --- a/GQ_TongXin/Assets/Adam/Scripts/DeviceManager.cs +++ b/GQ_TongXin/Assets/Adam/Scripts/DeviceManager.cs @@ -19,6 +19,8 @@ public class DeviceManager : MonoBehaviour public Transform dragControllerContent; public UPosManger uposManger; public GameObject stagingPanel; + + public Transform stagingParent; // Use this for initialization @@ -26,7 +28,7 @@ public class DeviceManager : MonoBehaviour private void Start() { editorMenu.gameObject.SetActive(false); - SwitchStagingPanel(); + SwitchStagingPanel(null); } public void SetDeviceItem(DeviceItem deviceItem) @@ -41,25 +43,49 @@ public class DeviceManager : MonoBehaviour 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 = dtPrefab; + dc.oriObjectPrefab = di.GetComponent(); dc.isSaveMode = true; uposManger.SetCurrentUPosIsOccupied(di.startIndex, di.volume, false); - Destroy(di.gameObject); + //Destroy(di.gameObject); + + di.transform.SetParent(stagingParent); + di.transform.localPosition = Vector3.zero; + di.gameObject.SetActive(false); + deviceItems.Remove(di); + editorMenu.gameObject.SetActive(false); - SwitchStagingPanel(); + SwitchStagingPanel(null); }); } - public void SwitchStagingPanel() + public void SwitchHighLight(DeviceItem di) { - Debug.Log("dragControllerContent.childCount=="+ dragControllerContent.childCount); - if (dragControllerContent.childCount > 0) - stagingPanel.SetActive(true); - else if (dragControllerContent.childCount == 0) - stagingPanel.SetActive(false); + for (int i = 0; i < deviceItems.Count; i++) + { + deviceItems[i].GetComponent().ShutDownHighlight(); + } + di.GetComponent().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); + } } diff --git a/GQ_TongXin/Assets/Adam/Scripts/DragController.cs b/GQ_TongXin/Assets/Adam/Scripts/DragController.cs index aadbe9972..1af0619a0 100644 --- a/GQ_TongXin/Assets/Adam/Scripts/DragController.cs +++ b/GQ_TongXin/Assets/Adam/Scripts/DragController.cs @@ -51,7 +51,13 @@ public class DragController : MonoBehaviour, IBeginDragHandler, IEndDragHandler, } public void OnBeginDrag(PointerEventData eventData) { - targetObject = Instantiate(oriObjectPrefab); + if (!isSaveMode) + targetObject = Instantiate(oriObjectPrefab); + else + { + targetObject = oriObjectPrefab; + targetObject.gameObject.SetActive(true); + } //currentDevice = targetObject.GetComponent(); targetObject.transform.eulerAngles = oriObjectPrefab.transform.eulerAngles; targetObject.transform.localScale = oriObjectPrefab.transform.lossyScale; @@ -87,23 +93,39 @@ public class DragController : MonoBehaviour, IBeginDragHandler, IEndDragHandler, if (targetObject == null) return; if (currentUPosItem == null) { - Destroy(targetObject.gameObject); + if (!isSaveMode) + Destroy(targetObject.gameObject); + else + targetObject.gameObject.SetActive(false); return; } if (currentUPosItem.isOccupied) { - Destroy(targetObject.gameObject); + if (!isSaveMode) + Destroy(targetObject.gameObject); + else + targetObject.gameObject.SetActive(false); return; } int index = uPosManger.CountUPos(targetObject.volume, currentUPosItem.ID); //Debug.Log("index-------------" + index); if (!CountUPos(targetObject, index)) - Destroy(targetObject.gameObject); + { + if (isSaveMode) + { + targetObject.gameObject.SetActive(false); + } + else + { + Destroy(targetObject.gameObject); + + } + } else { if (isSaveMode) { - Destroy(this.gameObject); + deviceManager.SwitchStagingPanel(this.gameObject); } } } @@ -121,7 +143,14 @@ public class DragController : MonoBehaviour, IBeginDragHandler, IEndDragHandler, dt.transform.localPosition = new Vector3(0.25f, 0, -0.045f * dt.volume + 0.0225f); uPosManger.SetCurrentUPosIsOccupied(index, dt.volume, true); - DeviceItem di = dt.gameObject.AddComponent(); + DeviceItem di; + if (dt.gameObject.GetComponent() == null) + di = dt.gameObject.AddComponent(); + else + di = dt.GetComponent(); + if (di.gameObject.GetComponent() == null) + di.gameObject.AddComponent(); + di.Init(deviceManager, index, dt.volume, oriObjectPrefab); deviceManager.SetDeviceItem(di); return true; @@ -141,7 +170,7 @@ public class DragController : MonoBehaviour, IBeginDragHandler, IEndDragHandler, target.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0, 0, 2)); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; - if (Physics.Raycast(ray, out hitInfo,100, 1 << 10)) + if (Physics.Raycast(ray, out hitInfo, 100, 1 << 10)) { if (hitInfo.collider != null && hitInfo.collider.GetComponent()) { diff --git a/GQ_TongXin/Assets/Scenes/SampleSceneG.unity b/GQ_TongXin/Assets/Scenes/SampleSceneG.unity index bdba979ef..cf16d2daf 100644 --- a/GQ_TongXin/Assets/Scenes/SampleSceneG.unity +++ b/GQ_TongXin/Assets/Scenes/SampleSceneG.unity @@ -30086,6 +30086,37 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!1 &296992421 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 296992422} + m_Layer: 0 + m_Name: Staging + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &296992422 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 296992421} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 33 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &297095067 GameObject: m_ObjectHideFlags: 0 @@ -110679,6 +110710,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} m_Name: m_EditorClassIdentifier: + m_SendPointerHoverToParent: 1 m_HorizontalAxis: Horizontal m_VerticalAxis: Vertical m_SubmitButton: Submit @@ -184195,7 +184227,7 @@ MonoBehaviour: xlz_xz: xlz_sc: arguments: - token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2OTMzNTg2MTUsInVzZXJuYW1lIjoiMTgzMTIzNDU2NzgifQ.5D98IIgWhtioVSpZtJ57HCvXHz1vZmBxCvXEwQFjaXQ + token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2OTM0MjU0NjYsInVzZXJuYW1lIjoiMTgzMTIzNDU2NzgifQ.pu-7H7D_99mF_rcTWJ33IfD6fSZlXKQCDeG1UsZDyP0 heatThresholdValueMax: heatThresholdValueMin: humidityThresholdValueMax: @@ -184459,6 +184491,7 @@ MonoBehaviour: dragControllerContent: {fileID: 155917792} uposManger: {fileID: 0} stagingPanel: {fileID: 803679558} + stagingParent: {fileID: 296992422} --- !u!1 &1816534963 GameObject: m_ObjectHideFlags: 0 diff --git a/GQ_TongXin/Packages/packages-lock.json b/GQ_TongXin/Packages/packages-lock.json index 0b07a465d..0858bf9be 100644 --- a/GQ_TongXin/Packages/packages-lock.json +++ b/GQ_TongXin/Packages/packages-lock.json @@ -28,8 +28,8 @@ "depth": 0, "source": "builtin", "dependencies": { - "com.unity.ide.visualstudio": "2.0.14", - "com.unity.ide.rider": "3.0.13", + "com.unity.ide.visualstudio": "2.0.16", + "com.unity.ide.rider": "3.0.15", "com.unity.ide.vscode": "1.2.5", "com.unity.editorcoroutines": "1.0.0", "com.unity.performance.profile-analyzer": "1.1.1", @@ -77,7 +77,7 @@ "url": "https://packages.unity.cn" }, "com.unity.services.core": { - "version": "1.3.1", + "version": "1.4.2", "depth": 1, "source": "registry", "dependencies": { diff --git a/GQ_TongXin/ProjectSettings/ProjectVersion.txt b/GQ_TongXin/ProjectSettings/ProjectVersion.txt index f9b5ef894..bc2ff9437 100644 --- a/GQ_TongXin/ProjectSettings/ProjectVersion.txt +++ b/GQ_TongXin/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2021.3.2f1c1 -m_EditorVersionWithRevision: 2021.3.2f1c1 (7ac240095d88) +m_EditorVersion: 2021.3.10f1c2 +m_EditorVersionWithRevision: 2021.3.10f1c2 (5a059dbcdda5)