feat: 添加打开Steam商店页功能

This commit is contained in:
2026-07-31 18:22:55 +08:00
parent 01cc5036d3
commit bd39c27c1d
3 changed files with 87 additions and 0 deletions
+1
View File
@@ -18,6 +18,7 @@ namespace AibisDream.Utility
public const string SurveyURL_JP = "https://jsj.top/f/icnVug";
public const string WishlistURL = "https://store.steampowered.com/app/3473430/_All_Our_Broken_Parts?utm_source=playtest";
public const string SteamWishlistURL = "steam://store/3473430";
public static readonly string SaveFilePath = Path.Combine(Application.persistentDataPath, "demo_saves");
#if UNITY_EDITOR || DEVELOPMENT_BUILD
@@ -0,0 +1,75 @@
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
using System.Runtime.InteropServices;
using System.Text;
#endif
using UnityEngine;
namespace AibisDream.Utility
{
/// <summary>
/// 打开游戏的 Steam 商店页面。
/// </summary>
public static class SteamStoreUtility
{
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
private const uint AssocStrCommand = 1;
private const int S_OK = 0;
[DllImport("Shlwapi.dll", CharSet = CharSet.Unicode)]
private static extern int AssocQueryString(
uint flags,
uint str,
string association,
string extra,
StringBuilder output,
ref uint outputLength);
#endif
/// <summary>
/// Windows 下优先使用 Steam 客户端;Steam 协议不可用时回退到网页商店。
/// </summary>
public static void OpenWishlistPage()
{
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
if (IsSteamProtocolRegistered())
{
Application.OpenURL(ConstRef.SteamWishlistURL);
return;
}
#endif
Application.OpenURL(ConstRef.WishlistURL);
}
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
private static bool IsSteamProtocolRegistered()
{
try
{
uint commandLength = 0;
AssocQueryString(0, AssocStrCommand, "steam", null, null, ref commandLength);
if (commandLength == 0)
{
return false;
}
var command = new StringBuilder((int)commandLength);
var result = AssocQueryString(
0,
AssocStrCommand,
"steam",
null,
command,
ref commandLength);
return result == S_OK && command.Length > 0;
}
catch (System.Exception exception)
{
Debug.LogWarning(
$"[SteamStoreUtility] 无法检测 Steam URL Protocol,将回退到网页商店:{exception.Message}");
return false;
}
}
#endif
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5d54f85d89d04849a54cde529cb66d55
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: