20261017
This commit is contained in:
1 parent
caf19faf09
commit
c4b10383f9
18 files changed
+3295
-1524
No files matched your search
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
// StartUI 與 InGame 共用的設定資料,存成 JSON
|
||||
[Serializable]
|
||||
public class GameSettings
|
||||
{
|
||||
// 貢獻者
|
||||
public string contributorID = "Anonymous";
|
||||
|
||||
// 一般設定
|
||||
public float sensitivity = 1.0f;
|
||||
public int fov = 90;
|
||||
|
||||
// 輔助設定 (0 = 無輔助, 1 = 直接移動準心, 2 = 動態靈敏度)
|
||||
public int assistMode = 0;
|
||||
public int assistStrength = 0; // 1~100 (%),無輔助時為 0
|
||||
public bool disableHorizontalAssist = false;
|
||||
public bool disableVerticalAssist = false;
|
||||
|
||||
// 系統資訊
|
||||
public int screenWidth;
|
||||
public int screenHeight;
|
||||
public int refreshRate;
|
||||
public string savedTime; // ISO 8601
|
||||
|
||||
// 檔案位置 : Windows 為 %USERPROFILE%/AppData/LocalLow/<公司>/<產品>/settings.json
|
||||
public static string FilePath => Path.Combine(Application.persistentDataPath, "settings.json");
|
||||
|
||||
public void Save()
|
||||
{
|
||||
File.WriteAllText(FilePath, JsonUtility.ToJson(this, true));
|
||||
}
|
||||
|
||||
// 讀不到檔案就回傳預設值
|
||||
public static GameSettings Load()
|
||||
{
|
||||
if (File.Exists(FilePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonUtility.FromJson<GameSettings>(File.ReadAllText(FilePath));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogWarning($"讀取設定失敗,改用預設值 : {e.Message}");
|
||||
}
|
||||
}
|
||||
return new GameSettings();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5dff0267e33ca77449f74683ee4cce39
|
||||
Reference in new issue
Block a user