71 lines
1.9 KiB
C#
71 lines
1.9 KiB
C#
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 Awake()
|
|
{
|
|
//#if VR
|
|
// gameObject.SetActive(false);
|
|
//#endif
|
|
}
|
|
private void Update()
|
|
{
|
|
Time.timeScale = animSpeed;
|
|
if (Input.GetKeyUp(KeyCode.F8))
|
|
{
|
|
animSpeed++;
|
|
}
|
|
if (Input.GetKeyUp(KeyCode.F7))
|
|
{
|
|
animSpeed--;
|
|
}
|
|
if (Input.GetKeyUp(KeyCode.F12))
|
|
{
|
|
animSpeed = 1;
|
|
}
|
|
if (Input.GetKeyUp(KeyCode.F11))
|
|
{
|
|
animSpeed = 0;
|
|
}
|
|
if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.C))
|
|
{
|
|
string str = string.Empty;
|
|
str = $"{gameObject.transform.position}|{gameObject.transform.eulerAngles}";
|
|
#if UNITY_WEBGL
|
|
Debug.Log("Ctrl + Q 被按下!"+str);
|
|
CopyToClipboard(str);
|
|
#elif UNITY_STANDALONE_WIN && !UNITY_EDITOR
|
|
// 示例数据
|
|
// 拷贝数据到剪贴板
|
|
GUIUtility.systemCopyBuffer = str;
|
|
#endif
|
|
}
|
|
#if UNITY_STANDALONE_WIN &&!UNITY_EDITOR
|
|
if (Input.GetKeyDown(KeyCode.V))
|
|
{
|
|
string tmp = GUIUtility.systemCopyBuffer;
|
|
Debug.Log("当前剪贴板:" + tmp);
|
|
tmp = tmp.Replace("(", "");
|
|
tmp = tmp.Replace(")", "");
|
|
var datas = tmp.Split('|');
|
|
|
|
gameObject.transform.position = Utility.GetVector3FromStrArray(datas[0]);
|
|
gameObject.transform.eulerAngles = Utility.GetVector3FromStrArray(datas[1]);
|
|
}
|
|
#endif
|
|
}
|
|
}
|
|
}
|