diff --git a/Assets/QFramework/Toolkits/UIKit/Scripts/Resources/VRUIRoot.prefab b/Assets/QFramework/Toolkits/UIKit/Scripts/Resources/VRUIRoot.prefab index 343b267b..7fc3f886 100644 --- a/Assets/QFramework/Toolkits/UIKit/Scripts/Resources/VRUIRoot.prefab +++ b/Assets/QFramework/Toolkits/UIKit/Scripts/Resources/VRUIRoot.prefab @@ -123,8 +123,8 @@ Transform: m_GameObject: {fileID: 598348144801550191} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0.1465, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalPosition: {x: 0, y: 2.1975, z: 0} + m_LocalScale: {x: 15, y: 15, z: 15} m_ConstrainProportionsScale: 0 m_Children: - {fileID: 5974269590546671381} @@ -144,7 +144,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Frame: {fileID: 6717849271440217812} - ViewerScale: 1 + ViewerScale: 15 --- !u!1 &765259898297824089 GameObject: m_ObjectHideFlags: 0 @@ -174,7 +174,7 @@ Transform: serializedVersion: 2 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_LocalScale: {x: 15, y: 15, z: 15} m_ConstrainProportionsScale: 0 m_Children: - {fileID: 964729101505013327} @@ -192,7 +192,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: b20817e9db276aa4182f6e0885aa2ddf, type: 3} m_Name: m_EditorClassIdentifier: - ViewerScale: 1 + ViewerScale: 15 --- !u!114 &2720570802681005941 MonoBehaviour: m_ObjectHideFlags: 0 @@ -634,7 +634,7 @@ Transform: m_GameObject: {fileID: 3400309332038407868} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: 0, y: 0, z: -0.000000059604645} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1129,7 +1129,7 @@ Transform: m_GameObject: {fileID: 4951725383111470759} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: 0, y: 0, z: -0.000000059604645} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] diff --git a/Assets/Scripts/Extension/DeviceDraggable.cs b/Assets/Scripts/Extension/DeviceDraggable.cs new file mode 100644 index 00000000..1e91f2fe --- /dev/null +++ b/Assets/Scripts/Extension/DeviceDraggable.cs @@ -0,0 +1,24 @@ +using GCSeries.Core.Samples; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.EventSystems; + +public class DeviceDraggable : Draggable +{ + Vector3 pos; + Vector3 rot; + private void Awake() + { + pos = transform.position; + rot = transform.localEulerAngles; + } + + public override void OnEndDrag(PointerEventData eventData) + { + base.OnEndDrag(eventData); + transform.position = pos; + transform.localEulerAngles = rot; + } + +} diff --git a/Assets/Scripts/Extension/DeviceDraggable.cs.meta b/Assets/Scripts/Extension/DeviceDraggable.cs.meta new file mode 100644 index 00000000..74aa391c --- /dev/null +++ b/Assets/Scripts/Extension/DeviceDraggable.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c2b2028d0dec50841b6e5477b275f265 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Item/DeviceItem.cs b/Assets/Scripts/Item/DeviceItem.cs index 81b8a599..dda21e49 100644 --- a/Assets/Scripts/Item/DeviceItem.cs +++ b/Assets/Scripts/Item/DeviceItem.cs @@ -54,6 +54,8 @@ public class DeviceItem : MonoBehaviour UIRoot.Instance.transform.Find("ZStylus").GetComponent().OnObjectExited.AddListener(OnObjExit); UIRoot.Instance.transform.Find("ZMouse").GetComponent().OnClick.AddListener(OnClick); UIRoot.Instance.transform.Find("ZStylus").GetComponent().OnClick.AddListener(OnClick); + + gameObject.GetOrAddComponent(); #endif } diff --git a/Assets/WebPlatform.meta b/Assets/WebPlatform.meta new file mode 100644 index 00000000..b4ce8b4f --- /dev/null +++ b/Assets/WebPlatform.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8daec37f39bdca34e922be7644ef97c1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/WebPlatform/LaiYiTe.meta b/Assets/WebPlatform/LaiYiTe.meta new file mode 100644 index 00000000..46d8f71e --- /dev/null +++ b/Assets/WebPlatform/LaiYiTe.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8f4e4f808ac25d946affe317d1b81545 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/WebPlatform/LaiYiTe/Resrouces.meta b/Assets/WebPlatform/LaiYiTe/Resrouces.meta new file mode 100644 index 00000000..9d6744c3 --- /dev/null +++ b/Assets/WebPlatform/LaiYiTe/Resrouces.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5da36794a84f2e24aa0626b1466f6360 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/WebPlatform/LaiYiTe/Resrouces/RSA.Private b/Assets/WebPlatform/LaiYiTe/Resrouces/RSA.Private new file mode 100644 index 00000000..3ead6dd1 --- /dev/null +++ b/Assets/WebPlatform/LaiYiTe/Resrouces/RSA.Private @@ -0,0 +1,10 @@ + + vsWZ0Eu/pLeJblZfeAQ7p+KWQHqiJnp9UNwfHLW8Ev2EI9Kg2aPiB/DGmhPab8yCfuQuZIqJSwcCX1XzVvtIOoeeKy53VHOity0oxADtoY+TZSbJraG0+kEwE+S8HZ8u8xAoVg1xcI1a/wnS2CmZSvoqwpOFKufcosyZZeWTyQXhTipL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wEX8x/mshQEHM6eH6oJczHhD+JU5QJvTg4CA6x/63C/lKfg6pwvmx3++MkITKjHhYLmI5HPS7G9SS98l1cdVx+BsK+YrWs2g97LHlDqqKs0busv9Kz3vZ/mIOHhL52OGthk7SBSL0Nbq5rCCyErQEKPk3HmVmF2nJTam3d1PK0OT7I4IH5Szn9CXt1R3kk1Y2NZb3GIrcPUaQ7+75/DlVL05Leabc/eMi/ghhyCqOotHnLw8uNf3kK6QvD/bv3C4Ikdy1ZYBpENz74OMeINWAEXZyARLgs4EryA+6F7Fw3magQ== +
\ No newline at end of file diff --git a/Assets/WebPlatform/LaiYiTe/Resrouces/RSA.Private.meta b/Assets/WebPlatform/LaiYiTe/Resrouces/RSA.Private.meta new file mode 100644 index 00000000..288425aa --- /dev/null +++ b/Assets/WebPlatform/LaiYiTe/Resrouces/RSA.Private.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 72fe0ae24cde45946914fa10b54896b0 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/WebPlatform/Plugins.meta b/Assets/WebPlatform/Plugins.meta new file mode 100644 index 00000000..83ed0eb0 --- /dev/null +++ b/Assets/WebPlatform/Plugins.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4a5ff23952c587c48ab012049e07df51 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/WebPlatform/Plugins/WebGL.meta b/Assets/WebPlatform/Plugins/WebGL.meta new file mode 100644 index 00000000..3a9a3ea3 --- /dev/null +++ b/Assets/WebPlatform/Plugins/WebGL.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 23a14a5f29ce27c4dab61a5fe698a2e9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/WebPlatform/Plugins/WebGL/GetParameters.jslib b/Assets/WebPlatform/Plugins/WebGL/GetParameters.jslib new file mode 100644 index 00000000..a460273f --- /dev/null +++ b/Assets/WebPlatform/Plugins/WebGL/GetParameters.jslib @@ -0,0 +1,9 @@ +// 名为 "URLParameters.jslib" 的插件文件 +mergeInto(LibraryManager.library, { + GetURLParameter: function (name) { + var search = window.location.search.substring(1); + var params = new URLSearchParams(search); + var value = params.get(name); + return value ? Pointer_stringify(value) : null; + } +}); \ No newline at end of file diff --git a/Assets/WebPlatform/Plugins/WebGL/GetParameters.jslib.meta b/Assets/WebPlatform/Plugins/WebGL/GetParameters.jslib.meta new file mode 100644 index 00000000..8e6335ec --- /dev/null +++ b/Assets/WebPlatform/Plugins/WebGL/GetParameters.jslib.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: af1b30451ed743d4f81b3f9c8c15baeb +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + WebGL: WebGL + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/WebPlatform/Scripts.meta b/Assets/WebPlatform/Scripts.meta new file mode 100644 index 00000000..978d3f73 --- /dev/null +++ b/Assets/WebPlatform/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b8dbba4c57255fc4495c422b41445cbe +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/WebPlatform/Scripts/WebGLHelper.cs b/Assets/WebPlatform/Scripts/WebGLHelper.cs new file mode 100644 index 00000000..ad0d032f --- /dev/null +++ b/Assets/WebPlatform/Scripts/WebGLHelper.cs @@ -0,0 +1,189 @@ +using Newtonsoft.Json; +using QFramework; +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Text; +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.Networking; + +public class WebGLHelper : Singleton +{ + private WebGLHelper() { } + public class LabData + { + public string GUID; + public string ExpID; + public string HOST; + public string PARA1; + public string PARA; + public string PARA2; + } + [DllImport("__Internal")] + private static extern string GetURLParameter(string name); + + string token = string.Empty; + + LabData labData = new LabData(); + [SerializeField] + private TextAsset RSA; + private const int RsaKeySize = 2048; + + public string uploadUrl; + + public void Init() + { + token = GetURLParameter("token").Replace("%2B", "+"); + RSA = Resources.Load("RSA"); + string urlData = Decrypt(token); + var datas = urlData.Split("&"); + labData.GUID = datas[0]; + labData.ExpID = datas[1]; + labData.HOST = datas[2]; + labData.PARA1 = datas[3]; + labData.PARA = datas[4]; + labData.PARA2 = datas[5]; + + uploadUrl = Path.Combine(labData.HOST, "host/public/Exp/AddScore/"); + } + /// + /// Decrypts encrypted text given a RSA private key file path.· RSA ˽Կļ + + /// + /// ܵ + /// ڼܵ˽Կ·. + /// δݵַ + public string Decrypt(string encryptedText) + { + using (var rsa = new RSACryptoServiceProvider(RsaKeySize)) + { + try + { + string privateXmlKey = RSA.text; + rsa.FromXmlString(privateXmlKey); + Debug.Log("encryptedText " + encryptedText); + var bytesEncrypted = Convert.FromBase64String(encryptedText); + string b = Encoding.UTF8.GetString(bytesEncrypted); + Debug.Log("byte " + b); + //var bytesPlainText = rsa.Decrypt(bytesEncrypted, false); + var bytesPlainText = rsa.Decrypt(bytesEncrypted, false); + Debug.Log("bytesPlainText " + bytesPlainText); + return System.Text.Encoding.UTF8.GetString(bytesPlainText); + } + finally + { + rsa.PersistKeyInCsp = false; + } + } + } + + + + public void UpLoadData(int totalScore, List stepNames, List maxScore, List score) + { + var data = new UploadData(); + data.GUID = labData.GUID; + data.ExpID = int.Parse(labData.ExpID); + data.score = totalScore; + data.flag = true; + + var list = new List(); + for (int i = 0; i < stepNames.Count; i++) + { + var step = new Expstepvtwolist(); + step.ExpStepName = stepNames[i]; + step.maxScore = maxScore[i]; + step.score = score[i]; + } + data.ExpStepVTwoList = list.ToArray(); + + + } + + IEnumerator SendScore(string json, UnityAction action) + { + if (string.IsNullOrEmpty(uploadUrl)) + { + Debug.LogError("ϴӿڵַ:" + uploadUrl); + yield break; + } + + using (UnityWebRequest request = new UnityWebRequest(uploadUrl, "POST")) + { + request.SetRequestHeader("Content-Type", "application/json"); + request.uploadHandler = new UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(json)); + request.downloadHandler = new DownloadHandlerBuffer(); + yield return request.SendWebRequest(); + // Ӧ + if (request.result == UnityWebRequest.Result.ConnectionError || + request.result == UnityWebRequest.Result.ProtocolError) + { + Debug.LogError($"Upload failed: {request.error}"); + Debug.LogError($"Response Code: {request.responseCode}"); + } + else + { + Debug.Log("Upload complete!"); + Debug.Log($"Response Code: {request.responseCode}"); + Debug.Log($"Server Response: {request.downloadHandler.text}"); + Response response = JsonConvert.DeserializeObject(request.downloadHandler.text); + Debug.LogError(response.msg); + } + } + + } +} + + + + +public class UploadData +{ + public string GUID { get; set; } + // ʵ ID + public int ExpID { get; set; } + // ɼ + public int score { get; set; } + // ־λĬֵ true + public bool flag { get; set; } + // ʵ鲽б + public Expstepvtwolist[] ExpStepVTwoList { get; set; } +} + +public class Expstepvtwolist +{ + // ʵ鲽 + public int seq { get; set; } + // ʵ鲽 + public string ExpStepName = ""; + // ʵ鲽״̬ + public string StepState = ""; + // ʵ鲽迪ʼʱ + public DateTime startTime = default; + // ʵ鲽ʱ + public DateTime endTime = default; + // ʵ鲽ʱλ + public int expectTime = 0; + // ʵ鲽֣0 ~100ٷ + public int maxScore = 100; + // ʵ鲽÷֣0 ~100ٷ + public int score = 0; + // ʵ鲽 + public int repeatCount = 1; + // ۣ200 + public string evaluation = ""; + // ģͣ200 + public string scoringModel = ""; + // ע + public string remarks { get; set; } +} + +public class Response +{ + public string msg; + public bool success; +} \ No newline at end of file diff --git a/Assets/WebPlatform/Scripts/WebGLHelper.cs.meta b/Assets/WebPlatform/Scripts/WebGLHelper.cs.meta new file mode 100644 index 00000000..a2f6aa5c --- /dev/null +++ b/Assets/WebPlatform/Scripts/WebGLHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c1b108973e2a6cd43bf6b1943d979a23 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: