新增工具扩展

This commit is contained in:
shenjianxing 2025-01-02 09:49:19 +08:00
parent bc24fdb3d8
commit ce4418010a
2 changed files with 32 additions and 3 deletions

View File

@ -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
}
}

View File

@ -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 {
}
}
});