diff --git a/Assets/Scenes/StartUI.unity b/Assets/Scenes/StartUI.unity index 76bf8cf..0b8a1ef 100644 --- a/Assets/Scenes/StartUI.unity +++ b/Assets/Scenes/StartUI.unity @@ -2402,6 +2402,9 @@ GameObject: - component: {fileID: 577747342} - component: {fileID: 577747341} - component: {fileID: 577747340} + - component: {fileID: 577747343} + - component: {fileID: 577747344} + - component: {fileID: 577747345} m_Layer: 5 m_Name: Notice_L m_TagString: Untagged @@ -2498,6 +2501,45 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 577747338} m_CullTransparentMesh: 1 +--- !u!114 &577747343 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 577747338} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d001489e65da58842bfcddcb83db1c54, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::IDManager + inputField: {fileID: 1976532343} + modeStatusText: {fileID: 260641034} +--- !u!114 &577747344 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 577747338} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dde79346c17b5f2459fc8a237791b65b, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::ResolutionDisplay + resolutionText: {fileID: 801092282} +--- !u!114 &577747345 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 577747338} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 20bda67a74291514cac9cd232e2093ee, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::PollingRate --- !u!1 &590569044 GameObject: m_ObjectHideFlags: 0 @@ -4859,8 +4901,8 @@ MonoBehaviour: m_fontMaterials: [] m_fontColor32: serializedVersion: 2 - rgba: 4291611852 - m_fontColor: {r: 0.8, g: 0.8, b: 0.8, a: 1} + rgba: 4293322470 + m_fontColor: {r: 0.9, g: 0.9, b: 0.9, a: 1} m_enableVertexGradient: 0 m_colorMode: 3 m_fontColorGradient: @@ -6304,7 +6346,7 @@ MonoBehaviour: m_PersistentCalls: m_Calls: [] m_text: "\t\u672C\u5C08\u6848\u65E8\u5728\u900F\u904E\u5927\u898F\u6A21\u63A1\u96C6\u771F\u5BE6\u73A9\u5BB6\u7684\u8F38\u5165\u884C\u70BA\u6578\u64DA\uFF0C\u5EFA\u7ACB\u5206\u6790\u6A21\u578B\u4EE5\u8B58\u5225\u8207\u5C0D\u6297\u904A\u6232\u4E2D\u7684 - AI \u8996\u89BA\u884C\u8F14\u52A9\u5916\u639B\u3002\u76F8\u95DC\u7814\u7A76\u6210\u679C\u8207\u6578\u64DA\u5206\u6790\u9810\u8A08\u5C07\u4F5C\u70BA\u5B78\u8853\u8AD6\u6587\u8207\u958B\u6E90\u9632\u8B77\u6A5F\u5236\u7684\u57FA\u790E\u3002" + AI \u8996\u89BA\u578B\u8F14\u52A9\u5916\u639B\u3002\u76F8\u95DC\u7814\u7A76\u6210\u679C\u8207\u6578\u64DA\u5206\u6790\u9810\u8A08\u5C07\u4F5C\u70BA\u5B78\u8853\u8AD6\u6587\u8207\u958B\u6E90\u9632\u8B77\u6A5F\u5236\u7684\u57FA\u790E\u3002" m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: a90984eb310cd5a449f31c00582b648a, type: 2} m_sharedMaterial: {fileID: 2808115657558496897, guid: a90984eb310cd5a449f31c00582b648a, type: 2} @@ -8499,7 +8541,7 @@ MonoBehaviour: m_HandleRect: {fileID: 590569045} m_Direction: 2 m_Value: 1 - m_Size: 0.6063342 + m_Size: 0.6059791 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: diff --git a/Assets/Stript/UI.meta b/Assets/Stript/StartUI_Interactions.meta similarity index 77% rename from Assets/Stript/UI.meta rename to Assets/Stript/StartUI_Interactions.meta index 652bd34..029e183 100644 --- a/Assets/Stript/UI.meta +++ b/Assets/Stript/StartUI_Interactions.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 35bbd284b4662a746b98e9f514d0cc13 +guid: 674c12e60bdde524494cfa1b2ceebf77 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Stript/StartUI_Interactions/IDManager.cs b/Assets/Stript/StartUI_Interactions/IDManager.cs new file mode 100644 index 0000000..ccd6fe0 --- /dev/null +++ b/Assets/Stript/StartUI_Interactions/IDManager.cs @@ -0,0 +1,54 @@ +using UnityEngine; +using TMPro; + +public class IDManager : MonoBehaviour +{ + [Header("UI 參照")] + public TMP_InputField inputField; + public TextMeshProUGUI modeStatusText; + private const int MaxLength = 12; + + void Start() + { + if (inputField != null) + { + inputField.characterLimit = MaxLength; + inputField.onValueChanged.AddListener(OnIDChanged); + OnIDChanged(inputField.text); + } + } + + void OnIDChanged(string currentText) + { + if (currentText.Length > MaxLength) + { + currentText = currentText.Substring(0, MaxLength); + inputField.text = currentText; + } + + if (string.IsNullOrEmpty(currentText.Trim())) + { + if (modeStatusText != null) + { + modeStatusText.text = "匿名模式"; + } + } + else + { + if (modeStatusText != null) + { + modeStatusText.text = "具名模式 : " + currentText; + } + } + } + + public string GetFinalContributorID() + { + string text = inputField.text.Trim(); + if (string.IsNullOrEmpty(text)) + { + return "Anonymous"; + } + return text; + } +} \ No newline at end of file diff --git a/Assets/Stript/StartUI_Interactions/IDManager.cs.meta b/Assets/Stript/StartUI_Interactions/IDManager.cs.meta new file mode 100644 index 0000000..9b00d83 --- /dev/null +++ b/Assets/Stript/StartUI_Interactions/IDManager.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: d001489e65da58842bfcddcb83db1c54 \ No newline at end of file diff --git a/Assets/Stript/StartUI_Interactions/PollingRate.cs b/Assets/Stript/StartUI_Interactions/PollingRate.cs new file mode 100644 index 0000000..deeb465 --- /dev/null +++ b/Assets/Stript/StartUI_Interactions/PollingRate.cs @@ -0,0 +1,71 @@ +using UnityEngine; +using UnityEngine.InputSystem; +using UnityEngine.InputSystem.LowLevel; +using System.Collections.Generic; + +public class MouseTrailLogger : MonoBehaviour +{ + // 定義單筆數據結構:包含時間戳記與當下的微小位移量 + [System.Serializable] + public struct MouseSample + { + public double timestamp; // 作業系統級別的時間戳記(秒,可換算為 ms) + public Vector2 delta; // 該瞬間的滑鼠位移量 (Delta) + } + + private List recordedSamples = new List(); + private bool isRecording = false; + + void OnEnable() + { + // 註冊 Input System 的底層事件攔截器 + InputSystem.onEvent += OnDataEvent; + } + + void OnDisable() + { + // 記得取消註冊,避免記憶體洩漏 + InputSystem.onEvent -= OnDataEvent; + } + + public void StartRecording() + { + recordedSamples.Clear(); + isRecording = true; + } + + public void StopRecording() + { + isRecording = false; + // 這裡可以把 recordedSamples 序列化成 JSON 準備上傳到 GitHub 或後端 + } + + private void OnDataEvent(InputEventPtr eventPtr, InputDevice device) + { + if (!isRecording) return; + + // 檢查這個事件是否由「滑鼠」發出,且是否包含狀態更新 + if (device is Mouse mouse) + { + // 判斷事件類型是否為滑鼠動態 (State Event) + if (eventPtr.IsA() || eventPtr.IsA()) + { + // 取得該事件發生時作業系統的高精度時間戳記 (Unscaled Time) + double eventTime = eventPtr.time; + + // 讀取當下的滑鼠位移量 + Vector2 mouseDelta = mouse.delta.ReadValue(); + + // 只有當滑鼠真有移動時才記錄,避免無效資料浪費記憶體 + if (mouseDelta != Vector2.zero) + { + recordedSamples.Add(new MouseSample + { + timestamp = eventTime, + delta = mouseDelta + }); + } + } + } + } +} \ No newline at end of file diff --git a/Assets/Stript/StartUI_Interactions/PollingRate.cs.meta b/Assets/Stript/StartUI_Interactions/PollingRate.cs.meta new file mode 100644 index 0000000..2056512 --- /dev/null +++ b/Assets/Stript/StartUI_Interactions/PollingRate.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 20bda67a74291514cac9cd232e2093ee \ No newline at end of file diff --git a/Assets/Stript/StartUI_Interactions/ResolutionDisplay.cs b/Assets/Stript/StartUI_Interactions/ResolutionDisplay.cs new file mode 100644 index 0000000..cc385ee --- /dev/null +++ b/Assets/Stript/StartUI_Interactions/ResolutionDisplay.cs @@ -0,0 +1,37 @@ +using UnityEngine; +using TMPro; + +public class ResolutionDisplay : MonoBehaviour +{ + [Header("UI 參照")] + public TextMeshProUGUI resolutionText; + private int lastWidth = 0; + private int lastHeight = 0; + + void Update() + { + int currentWidth = Screen.width; + int currentHeight = Screen.height; + + if (currentWidth != lastWidth || currentHeight != lastHeight) + { + lastWidth = currentWidth; + lastHeight = currentHeight; + UpdateResolutionText(currentWidth, currentHeight); + } + } + + void UpdateResolutionText(int w, int h) + { + if (resolutionText == null) return; + + + int refreshRate = 60; + + if (Screen.currentResolution.refreshRateRatio.value > 0) + { + refreshRate = Mathf.RoundToInt((float)Screen.currentResolution.refreshRateRatio.value); + } + resolutionText.text = $"解析度 : {w}*{h}*{refreshRate}hz"; + } +} \ No newline at end of file diff --git a/Assets/Stript/StartUI_Interactions/ResolutionDisplay.cs.meta b/Assets/Stript/StartUI_Interactions/ResolutionDisplay.cs.meta new file mode 100644 index 0000000..91621a6 --- /dev/null +++ b/Assets/Stript/StartUI_Interactions/ResolutionDisplay.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: dde79346c17b5f2459fc8a237791b65b \ No newline at end of file