From ce4418010a51d52d9c331b1791e3075a79f1378c Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Thu, 2 Jan 2025 09:49:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B7=A5=E5=85=B7=E6=89=A9?= =?UTF-8?q?=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/TimeScaleController.cs | 21 +++++++++++++++++-- .../Plugins/WebGLDownloadFile.jslib | 14 ++++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/TimeScaleController.cs b/Assets/Scripts/TimeScaleController.cs index d2afdbe3..8699dd02 100644 --- a/Assets/Scripts/TimeScaleController.cs +++ b/Assets/Scripts/TimeScaleController.cs @@ -1,13 +1,16 @@ +using QFramework; using System.Collections; using System.Collections.Generic; using UnityEngine; - public class TimeScaleController : MonoBehaviour { [Range(0, 10)] public float animSpeed = 1.0f; - +#if UNITY_WEBGL + [System.Runtime.InteropServices.DllImport("__Internal")] + private static extern void CopyToClipboard(string text); +#endif private void Update() { @@ -28,6 +31,20 @@ public class TimeScaleController : MonoBehaviour { animSpeed = 0; } +#if UNITY_WEBGL + if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightControl)) + { + if (Input.GetKeyDown(KeyCode.W)) + { + Debug.Log("Ctrl + W £"); + string str = string.Empty; + str = $"Posision:{gameObject.transform.position}\nRotate:{gameObject.transform.eulerAngles}"; + + CopyToClipboard(str); + + } + } +#endif } } diff --git a/Assets/WebGLDownLoadWord/Plugins/WebGLDownloadFile.jslib b/Assets/WebGLDownLoadWord/Plugins/WebGLDownloadFile.jslib index 925f54ef..dcdfd155 100644 --- a/Assets/WebGLDownLoadWord/Plugins/WebGLDownloadFile.jslib +++ b/Assets/WebGLDownLoadWord/Plugins/WebGLDownloadFile.jslib @@ -11,5 +11,17 @@ mergeInto(LibraryManager.library, { HtmlDownloadWord(bytes,reportdata); - } + }, + CopyToClipboard: function(text) { + + var str = Pointer_stringify(text); + + + if (navigator.clipboard) { + navigator.clipboard.writeText(str).then(function() { + }).catch(function(error) { + }); + } else { + } + } });