VirtualFramework/Assets/Scripts/TimeScaleController.cs

75 lines
2.1 KiB
C#
Raw Normal View History

2025-01-02 09:49:19 +08:00
using QFramework;
2024-12-27 17:25:30 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TimeScaleController : MonoBehaviour
{
[Range(0, 10)]
public float animSpeed = 1.0f;
2025-01-02 09:49:19 +08:00
#if UNITY_WEBGL
[System.Runtime.InteropServices.DllImport("__Internal")]
private static extern void CopyToClipboard(string text);
#endif
2024-12-27 17:25:30 +08:00
2025-01-03 17:00:55 +08:00
private void Awake()
{
#if VR
gameObject.SetActive(false);
#endif
}
2024-12-27 17:25:30 +08:00
private void Update()
{
Time.timeScale = animSpeed;
2024-12-30 11:42:27 +08:00
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;
}
2025-01-02 10:24:55 +08:00
if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
2025-01-02 09:49:19 +08:00
{
2025-01-02 10:24:01 +08:00
if (Input.GetKeyDown(KeyCode.Q))
2025-01-02 09:49:19 +08:00
{
string str = string.Empty;
2025-01-03 17:37:06 +08:00
str = $"{gameObject.transform.position}|{gameObject.transform.eulerAngles}";
#if UNITY_WEBGL
Debug.Log("Ctrl + Q <20><><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>");
2025-01-02 09:49:19 +08:00
CopyToClipboard(str);
2025-01-03 17:37:06 +08:00
#elif UNITY_STANDALONE_WIN && !UNITY_EDITOR
// ʾ<><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
GUIUtility.systemCopyBuffer = str;
#endif
}
#if UNITY_STANDALONE_WIN &&!UNITY_EDITOR
if (Input.GetKeyDown(KeyCode.E))
{
string tmp = GUIUtility.systemCopyBuffer;
Debug.LogError("<22><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>壺" + tmp);
tmp = tmp.Replace("(", "");
Debug.LogError(tmp);
tmp = tmp.Replace(")", "");
Debug.LogError(tmp);
var datas = tmp.Split('|');
2025-01-02 09:49:19 +08:00
2025-01-03 17:37:06 +08:00
Debug.LogError(datas[0]);
Debug.LogError(datas[1]);
gameObject.transform.position = Utility.GetVector3FromStrArray(datas[0]);
gameObject.transform.eulerAngles = Utility.GetVector3FromStrArray(datas[1]);
2025-01-02 09:49:19 +08:00
}
#endif
2025-01-03 17:37:06 +08:00
}
2024-12-27 17:25:30 +08:00
}
}