com.xd.sdk.common 7.2.1-alpha.3 → 7.2.1-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Editor/Steam/SteamBuildProcessor.cs +4 -2
- package/Plugins/Android/libs/XDGBridgeCommon_v7_7.3.0.aar +0 -0
- package/Plugins/Android/libs/XDGCommon_7.3.0.aar +0 -0
- package/Plugins/Android/libs/XDGTapSdkCompat_7.3.0.aar +0 -0
- package/Plugins/Android/libs/{XDGTapTapWrapperInternal_7.2.0.aar.meta → XDGTapSdkCompat_7.3.0.aar.meta} +1 -1
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDVersion.h +1 -1
- package/Plugins/iOS/XDCommonSDK.framework/XDCommonSDK +0 -0
- package/Plugins/iOS/XDTapSDK4WrapperSDK.framework/Headers/XDGTapTapAchievementCallback.h.meta +7 -0
- package/Plugins/iOS/XDTapSDK4WrapperSDK.framework/Headers/XDGTapTapAchievementWrapper.h.meta +7 -0
- package/Plugins/iOS/XDTapSDK4WrapperSDK.framework/Headers/XDGTapTapCloudSaveCallback.h.meta +7 -0
- package/Plugins/iOS/XDTapSDK4WrapperSDK.framework/Headers/XDGTapTapCloudSaveWrapper.h.meta +7 -0
- package/Plugins/iOS/XDTapSDK4WrapperSDK.framework/Headers/XDGTapTapMomentDelegate.h.meta +7 -0
- package/Plugins/iOS/XDTapSDK4WrapperSDK.framework/Headers/XDGTapTapMomentWrapper.h.meta +7 -0
- package/Plugins/iOS/XDTapSDK4WrapperSDK.framework/Headers/XDTapSDK4WrapperSDK.h +1 -1
- package/Resources/Prefabs/GeneralAgreementAlert.prefab +4 -4
- package/Resources/Prefabs/XDSDKUI.prefab +13 -0
- package/Runtime/Internal/IXDGCommon.Extended.cs +0 -4
- package/Runtime/Internal/Mobile/CommonFeaturesImpl.cs +20 -0
- package/Runtime/Internal/Standalone/CommonFeaturesImpl.cs +11 -1
- package/Runtime/Internal/Standalone/Steam/SteamManager.cs +8 -2
- package/Runtime/Internal/Standalone/Steam/SteamUtils.cs +75 -0
- package/Runtime/Internal/Standalone/Steam/SteamUtils.cs.meta +3 -0
- package/Runtime/Internal/Standalone/Steam/SteamWrapper.cs +11 -32
- package/Runtime/Internal/Standalone/UI/Base/UIResolutionAdapter.cs +1 -0
- package/Runtime/Internal/Standalone/UI/Base/UIResolutionAdapter.cs.meta +3 -0
- package/Runtime/Internal/XDGCommonInternal.cs +5 -0
- package/Runtime/Public/XDGCommon.cs +21 -0
- package/package.json +2 -2
- package/Plugins/Android/libs/XDGBridgeCommon_v7_7.2.0.aar +0 -0
- package/Plugins/Android/libs/XDGCommon_7.2.0.aar +0 -0
- package/Plugins/Android/libs/XDGTapTapWrapperInternal_7.2.0.aar +0 -0
- package/Plugins/Android/libs/XDTapTapWrapper_7.2.0.aar +0 -0
- package/Plugins/Android/libs/XDTapTapWrapper_7.2.0.aar.meta +0 -32
- /package/Plugins/Android/libs/{XDGBridgeCommon_v7_7.2.0.aar.meta → XDGBridgeCommon_v7_7.3.0.aar.meta} +0 -0
- /package/Plugins/Android/libs/{XDGCommon_7.2.0.aar.meta → XDGCommon_7.3.0.aar.meta} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#if XD_STEAM_SUPPORT
|
|
1
2
|
using System.IO;
|
|
2
3
|
using UnityEngine;
|
|
3
4
|
using UnityEditor;
|
|
@@ -18,7 +19,7 @@ namespace XD.SDK.Common.Internal.Standalone.Editor {
|
|
|
18
19
|
string appIdTxt = "steam_appid.txt";
|
|
19
20
|
string appIdTxtPath = Path.Combine(Application.dataPath, "..", appIdTxt);
|
|
20
21
|
if (!File.Exists(appIdTxtPath)) {
|
|
21
|
-
Debug.
|
|
22
|
+
Debug.LogWarning($"请将 steam_appid.txt 放置在工程根目录下。");
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
string outPath = report.summary.outputPath;
|
|
@@ -32,4 +33,5 @@ namespace XD.SDK.Common.Internal.Standalone.Editor {
|
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
|
-
}
|
|
36
|
+
}
|
|
37
|
+
#endif
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -133,7 +133,7 @@ MonoBehaviour:
|
|
|
133
133
|
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
|
134
134
|
m_Name:
|
|
135
135
|
m_EditorClassIdentifier:
|
|
136
|
-
m_Material: {fileID:
|
|
136
|
+
m_Material: {fileID: 0}
|
|
137
137
|
m_Color: {r: 0.13333334, g: 0.13333334, b: 0.13333334, a: 1}
|
|
138
138
|
m_RaycastTarget: 1
|
|
139
139
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
|
@@ -187,9 +187,9 @@ RectTransform:
|
|
|
187
187
|
m_Children: []
|
|
188
188
|
m_Father: {fileID: 8115389968904905495}
|
|
189
189
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
190
|
-
m_AnchorMin: {x: 0, y:
|
|
191
|
-
m_AnchorMax: {x: 0, y:
|
|
192
|
-
m_AnchoredPosition: {x: 400, y:
|
|
190
|
+
m_AnchorMin: {x: 0, y: 1}
|
|
191
|
+
m_AnchorMax: {x: 0, y: 1}
|
|
192
|
+
m_AnchoredPosition: {x: 400, y: -348}
|
|
193
193
|
m_SizeDelta: {x: 700, y: 0}
|
|
194
194
|
m_Pivot: {x: 0.5, y: 1}
|
|
195
195
|
--- !u!114 &6136117534961052962
|
|
@@ -87,6 +87,7 @@ GameObject:
|
|
|
87
87
|
- component: {fileID: 223190507069427674}
|
|
88
88
|
- component: {fileID: 114453665955884244}
|
|
89
89
|
- component: {fileID: 114536875208541376}
|
|
90
|
+
- component: {fileID: 1723631138956368394}
|
|
90
91
|
m_Layer: 5
|
|
91
92
|
m_Name: XDSDKUI
|
|
92
93
|
m_TagString: Untagged
|
|
@@ -180,6 +181,18 @@ MonoBehaviour:
|
|
|
180
181
|
m_BlockingMask:
|
|
181
182
|
serializedVersion: 2
|
|
182
183
|
m_Bits: 4294967295
|
|
184
|
+
--- !u!114 &1723631138956368394
|
|
185
|
+
MonoBehaviour:
|
|
186
|
+
m_ObjectHideFlags: 0
|
|
187
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
188
|
+
m_PrefabInstance: {fileID: 0}
|
|
189
|
+
m_PrefabAsset: {fileID: 0}
|
|
190
|
+
m_GameObject: {fileID: 1810664746418960}
|
|
191
|
+
m_Enabled: 1
|
|
192
|
+
m_EditorHideFlags: 0
|
|
193
|
+
m_Script: {fileID: 11500000, guid: c91453437c3342b99c78c23bcc9e028f, type: 3}
|
|
194
|
+
m_Name:
|
|
195
|
+
m_EditorClassIdentifier:
|
|
183
196
|
--- !u!1 &6203735995377905587
|
|
184
197
|
GameObject:
|
|
185
198
|
m_ObjectHideFlags: 0
|
|
@@ -229,6 +229,26 @@ namespace XD.SDK.Common.Internal.Mobile
|
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
+
public string GetPackageType()
|
|
233
|
+
{
|
|
234
|
+
string packageType = XDGPackageType.PackageTypeDefault;
|
|
235
|
+
#if UNITY_ANDROID
|
|
236
|
+
using (var commonBridgeClass = new AndroidJavaClass(BridgeConstants.Common.BridgeStaticImpl))
|
|
237
|
+
{
|
|
238
|
+
packageType = commonBridgeClass.CallStatic<string>("getPackageType");
|
|
239
|
+
}
|
|
240
|
+
#elif UNITY_IOS
|
|
241
|
+
IntPtr ptr = XDCommonBridgeGetPackageType();
|
|
242
|
+
packageType = Marshal.PtrToStringAnsi(ptr);
|
|
243
|
+
#endif
|
|
244
|
+
return packageType;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
#if UNITY_IOS
|
|
248
|
+
[DllImport("__Internal")]
|
|
249
|
+
private static extern IntPtr XDCommonBridgeGetPackageType();
|
|
250
|
+
#endif
|
|
251
|
+
|
|
232
252
|
public bool IsSteamInitialized()
|
|
233
253
|
{
|
|
234
254
|
return false;
|
|
@@ -104,9 +104,19 @@ namespace XD.SDK.Common.Internal.Standalone
|
|
|
104
104
|
#endif
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
public string GetPackageType()
|
|
108
|
+
{
|
|
109
|
+
if (SteamUtils.IsSDKSupported)
|
|
110
|
+
{
|
|
111
|
+
return XDGPackageType.PackageTypePCSteam;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return ConfigModule.UsingTapPC ? XDGPackageType.PackageTypePCTapTap : XDGPackageType.PackageTypePCNormal;
|
|
115
|
+
}
|
|
116
|
+
|
|
107
117
|
public bool IsSteamInitialized()
|
|
108
118
|
{
|
|
109
|
-
return
|
|
119
|
+
return SteamUtils.IsSDKSupported;
|
|
110
120
|
}
|
|
111
121
|
|
|
112
122
|
public void DisableAgreementUI()
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#if XD_STEAM_SUPPORT
|
|
1
2
|
// The SteamManager is designed to work with Steamworks.NET
|
|
2
3
|
// This file is released into the public domain.
|
|
3
4
|
// Where that dedication is not recognized you are granted a perpetual,
|
|
@@ -319,7 +320,11 @@ class SteamManager : MonoBehaviour {
|
|
|
319
320
|
{
|
|
320
321
|
var json = File.ReadAllText(configPath);
|
|
321
322
|
var jsonObject = JObject.Parse(json);
|
|
322
|
-
var steamIDRaw = jsonObject["
|
|
323
|
+
var steamIDRaw = jsonObject["steam_appid"]?.ToString();
|
|
324
|
+
if (string.IsNullOrEmpty(steamIDRaw))
|
|
325
|
+
{
|
|
326
|
+
steamIDRaw = jsonObject["steam_id"]?.ToString();
|
|
327
|
+
}
|
|
323
328
|
|
|
324
329
|
ulong steamIDValue = 0;
|
|
325
330
|
if (!string.IsNullOrEmpty(steamIDRaw) && !ulong.TryParse(steamIDRaw, out steamIDValue))
|
|
@@ -357,4 +362,5 @@ class SteamManager : MonoBehaviour {
|
|
|
357
362
|
}
|
|
358
363
|
}
|
|
359
364
|
#endif // !DISABLESTEAMWORKS
|
|
360
|
-
}
|
|
365
|
+
}
|
|
366
|
+
#endif // XD_STEAM_SUPPORT
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Linq;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
|
|
5
|
+
namespace XD.SDK.Common.Internal.Standalone
|
|
6
|
+
{
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Steam SDK 封装接口
|
|
9
|
+
/// </summary>
|
|
10
|
+
public interface ISteamSDKWrapper
|
|
11
|
+
{
|
|
12
|
+
Task<string> GetAuthTicket();
|
|
13
|
+
string GetSteamId();
|
|
14
|
+
string GetSteamLanguage();
|
|
15
|
+
Task<string> GetMicroTxn(ulong orderId);
|
|
16
|
+
string GetSteamCountry();
|
|
17
|
+
bool IsInitialized();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public class SteamUtils
|
|
21
|
+
{
|
|
22
|
+
private static readonly Lazy<SteamUtils> _instance = new Lazy<SteamUtils>(() => new SteamUtils());
|
|
23
|
+
public static SteamUtils Instance => _instance.Value;
|
|
24
|
+
|
|
25
|
+
private SteamUtils()
|
|
26
|
+
{
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private static ISteamSDKWrapper WrapperInstance { get; set; }
|
|
30
|
+
|
|
31
|
+
static SteamUtils()
|
|
32
|
+
{
|
|
33
|
+
Type interfaceType = typeof(ISteamSDKWrapper);
|
|
34
|
+
Type steamWrapperType = AppDomain.CurrentDomain.GetAssemblies()
|
|
35
|
+
.SelectMany(assembly => assembly.GetTypes())
|
|
36
|
+
.FirstOrDefault(clazz => interfaceType.IsAssignableFrom(clazz) && clazz.IsClass);
|
|
37
|
+
if (steamWrapperType != null)
|
|
38
|
+
{
|
|
39
|
+
WrapperInstance = Activator.CreateInstance(steamWrapperType) as ISteamSDKWrapper;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public Task<string> GetAuthTicket()
|
|
44
|
+
{
|
|
45
|
+
return IsInitialized() ? WrapperInstance.GetAuthTicket() : Task.FromResult(string.Empty);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public string GetSteamId()
|
|
49
|
+
{
|
|
50
|
+
return IsInitialized() ? WrapperInstance.GetSteamId() : string.Empty;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public string GetSteamLanguage()
|
|
54
|
+
{
|
|
55
|
+
return IsInitialized() ? WrapperInstance.GetSteamLanguage() : string.Empty;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public Task<string> GetMicroTxn(ulong orderId)
|
|
59
|
+
{
|
|
60
|
+
return IsInitialized() ? WrapperInstance.GetMicroTxn(orderId) : Task.FromResult(string.Empty);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public string GetSteamCountry()
|
|
64
|
+
{
|
|
65
|
+
return IsInitialized() ? WrapperInstance.GetSteamCountry() : string.Empty;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public bool IsInitialized()
|
|
69
|
+
{
|
|
70
|
+
return WrapperInstance != null && WrapperInstance.IsInitialized();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public static bool IsSDKSupported => Instance.IsInitialized();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -1,30 +1,24 @@
|
|
|
1
|
+
#if XD_STEAM_SUPPORT
|
|
1
2
|
#if UNITY_EDITOR || UNITY_STANDALONE
|
|
2
3
|
using System;
|
|
3
4
|
using System.Collections.Generic;
|
|
4
5
|
using System.Collections.Concurrent;
|
|
5
6
|
using System.Threading.Tasks;
|
|
6
7
|
using Newtonsoft.Json;
|
|
7
|
-
#if !UNITY_IOS && !UNITY_ANDROID
|
|
8
8
|
using Steamworks;
|
|
9
|
-
#endif
|
|
10
9
|
|
|
11
10
|
namespace XD.SDK.Common.Internal.Standalone
|
|
12
11
|
{
|
|
13
|
-
public class SteamWrapper
|
|
12
|
+
public class SteamWrapper : ISteamSDKWrapper
|
|
14
13
|
{
|
|
15
|
-
private static readonly Lazy<SteamWrapper> lazyInstance = new Lazy<SteamWrapper>(() => new SteamWrapper());
|
|
16
|
-
#if !UNITY_IOS && !UNITY_ANDROID
|
|
17
14
|
private readonly Callback<GetAuthSessionTicketResponse_t> getAuthSessionTicketResponseCallback;
|
|
18
15
|
private readonly ConcurrentDictionary<HAuthTicket, Tuple<TaskCompletionSource<string>, string>> tickTasks;
|
|
19
16
|
|
|
20
17
|
private readonly Callback<MicroTxnAuthorizationResponse_t> mircoTxnAuthorizationCallback;
|
|
21
18
|
private readonly ConcurrentDictionary<ulong, TaskCompletionSource<string>> microTxnTasks;
|
|
22
|
-
#endif
|
|
23
|
-
public static SteamWrapper Instance => lazyInstance.Value;
|
|
24
19
|
|
|
25
|
-
|
|
20
|
+
public SteamWrapper()
|
|
26
21
|
{
|
|
27
|
-
#if !UNITY_IOS && !UNITY_ANDROID
|
|
28
22
|
tickTasks = new ConcurrentDictionary<HAuthTicket, Tuple<TaskCompletionSource<string>, string>>();
|
|
29
23
|
|
|
30
24
|
getAuthSessionTicketResponseCallback = Callback<GetAuthSessionTicketResponse_t>.Create((GetAuthSessionTicketResponse_t pCallback) =>
|
|
@@ -61,10 +55,9 @@ namespace XD.SDK.Common.Internal.Standalone
|
|
|
61
55
|
}
|
|
62
56
|
}
|
|
63
57
|
});
|
|
64
|
-
#endif
|
|
65
58
|
}
|
|
66
59
|
|
|
67
|
-
|
|
60
|
+
private static bool Initialized()
|
|
68
61
|
{
|
|
69
62
|
return SteamManager.Initialized;
|
|
70
63
|
}
|
|
@@ -79,7 +72,6 @@ namespace XD.SDK.Common.Internal.Standalone
|
|
|
79
72
|
|
|
80
73
|
public Task<string> GetAuthTicket()
|
|
81
74
|
{
|
|
82
|
-
#if !UNITY_IOS && !UNITY_ANDROID
|
|
83
75
|
EnsureInitialized();
|
|
84
76
|
TaskCompletionSource<string> tcs = new TaskCompletionSource<string>();
|
|
85
77
|
|
|
@@ -88,11 +80,8 @@ namespace XD.SDK.Common.Internal.Standalone
|
|
|
88
80
|
string ticket = BitConverter.ToString(data, 0, (int)ticketLength)
|
|
89
81
|
.Replace("-", string.Empty);
|
|
90
82
|
tickTasks.TryAdd(hTicket, new Tuple<TaskCompletionSource<string>, string>(tcs, ticket));
|
|
91
|
-
|
|
83
|
+
|
|
92
84
|
return tcs.Task;
|
|
93
|
-
#else
|
|
94
|
-
throw new Exception("Steam is not supported on iOS/Android platform.");
|
|
95
|
-
#endif
|
|
96
85
|
}
|
|
97
86
|
|
|
98
87
|
/// <summary>
|
|
@@ -102,19 +91,14 @@ namespace XD.SDK.Common.Internal.Standalone
|
|
|
102
91
|
/// <returns></returns>
|
|
103
92
|
public Task<string> GetMicroTxn(ulong orderId)
|
|
104
93
|
{
|
|
105
|
-
#if !UNITY_IOS && !UNITY_ANDROID
|
|
106
94
|
EnsureInitialized();
|
|
107
95
|
TaskCompletionSource<string> tcs = new TaskCompletionSource<string>();
|
|
108
96
|
microTxnTasks.TryAdd(orderId, tcs);
|
|
109
97
|
return tcs.Task;
|
|
110
|
-
#else
|
|
111
|
-
throw new Exception("Steam is not supported on iOS/Android platform.");
|
|
112
|
-
#endif
|
|
113
98
|
}
|
|
114
99
|
|
|
115
100
|
public string GetSteamId()
|
|
116
101
|
{
|
|
117
|
-
#if !UNITY_IOS && !UNITY_ANDROID
|
|
118
102
|
EnsureInitialized();
|
|
119
103
|
try
|
|
120
104
|
{
|
|
@@ -126,24 +110,16 @@ namespace XD.SDK.Common.Internal.Standalone
|
|
|
126
110
|
XDGLogger.Error("当前开启 XD_STEAM_SUPPORT,但没有 Steam 环境", XDGLoggerTag.Common);
|
|
127
111
|
return null;
|
|
128
112
|
}
|
|
129
|
-
#else
|
|
130
|
-
throw new Exception("Steam is not supported on iOS/Android platform.");
|
|
131
|
-
#endif
|
|
132
113
|
}
|
|
133
114
|
|
|
134
115
|
public string GetSteamLanguage()
|
|
135
116
|
{
|
|
136
|
-
#if !UNITY_IOS && !UNITY_ANDROID
|
|
137
117
|
EnsureInitialized();
|
|
138
118
|
return SteamApps.GetCurrentGameLanguage();
|
|
139
|
-
#else
|
|
140
|
-
throw new Exception("Steam is not supported on iOS/Android platform.");
|
|
141
|
-
#endif
|
|
142
119
|
}
|
|
143
120
|
|
|
144
121
|
public string GetSteamCountry()
|
|
145
122
|
{
|
|
146
|
-
#if !UNITY_IOS && !UNITY_ANDROID
|
|
147
123
|
if (!Initialized())
|
|
148
124
|
{
|
|
149
125
|
return null;
|
|
@@ -156,11 +132,14 @@ namespace XD.SDK.Common.Internal.Standalone
|
|
|
156
132
|
{
|
|
157
133
|
return null;
|
|
158
134
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public bool IsInitialized()
|
|
138
|
+
{
|
|
139
|
+
return Initialized();
|
|
162
140
|
}
|
|
163
141
|
}
|
|
164
142
|
}
|
|
165
143
|
|
|
144
|
+
#endif
|
|
166
145
|
#endif
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
[RequireComponent(typeof(CanvasScaler))]
|
|
1
3
|
public class UIResolutionAdapter : MonoBehaviour
|
|
2
4
|
{
|
|
3
5
|
private static Vector2 _globalTargetResolution = new Vector2(1920, 1080);
|
|
4
6
|
private static bool _isConfigLoaded;
|
|
5
7
|
private CanvasScaler scaler;
|
|
6
8
|
private void Awake()
|
|
7
9
|
{
|
|
8
10
|
LoadConfigOnce();
|
|
9
11
|
scaler = GetComponent<CanvasScaler>();
|
|
10
12
|
Adapt();
|
|
11
13
|
}
|
|
12
14
|
void OnRectTransformDimensionsChange()
|
|
13
15
|
{
|
|
14
16
|
if (!Application.isPlaying)
|
|
15
17
|
{
|
|
16
18
|
_isConfigLoaded = false;
|
|
17
19
|
LoadConfigOnce();
|
|
18
20
|
}
|
|
19
21
|
Adapt();
|
|
20
22
|
}
|
|
21
23
|
// --- 核心适配逻辑 ---
|
|
22
24
|
public void Adapt()
|
|
23
25
|
{
|
|
24
26
|
if (scaler == null) scaler = GetComponent<CanvasScaler>();
|
|
25
27
|
if (scaler == null) return;
|
|
26
28
|
scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
|
|
27
29
|
float maxVal = Mathf.Max(_globalTargetResolution.x, _globalTargetResolution.y);
|
|
28
30
|
float minVal = Mathf.Min(_globalTargetResolution.x, _globalTargetResolution.y);
|
|
29
31
|
float screenRatio = (float)Screen.width / Screen.height;
|
|
30
32
|
if (screenRatio > 1)
|
|
31
33
|
{
|
|
32
34
|
scaler.referenceResolution = new Vector2(maxVal, minVal);
|
|
33
35
|
scaler.matchWidthOrHeight = 1.0f;
|
|
34
36
|
}
|
|
35
37
|
else
|
|
36
38
|
{
|
|
37
39
|
scaler.referenceResolution = new Vector2(minVal, maxVal);
|
|
38
40
|
scaler.matchWidthOrHeight = 0.0f;
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
private static void LoadConfigOnce()
|
|
42
44
|
{
|
|
43
45
|
if (_isConfigLoaded) return;
|
|
44
46
|
_isConfigLoaded = true;
|
|
45
47
|
string filePath = Path.Combine(Application.streamingAssetsPath, "XDConfig.json");
|
|
46
48
|
try
|
|
47
49
|
{
|
|
48
50
|
if (File.Exists(filePath))
|
|
49
51
|
{
|
|
50
52
|
var jsonContent = File.ReadAllText(filePath);
|
|
51
53
|
var match = Regex.Match(jsonContent, "\"ui_resolution\"\\s*:\\s*\\[\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\]");
|
|
52
54
|
if (!match.Success) return;
|
|
53
55
|
var w = float.Parse(match.Groups[1].Value);
|
|
54
56
|
var h = float.Parse(match.Groups[2].Value);
|
|
55
57
|
_globalTargetResolution = new Vector2(w, h);
|
|
56
58
|
Debug.Log($"[XDSDK] UI配置已加载: {_globalTargetResolution}");
|
|
57
59
|
}
|
|
58
60
|
else
|
|
59
61
|
{
|
|
60
62
|
Debug.LogWarning($"[XDSDK] 找不到配置文件: {filePath},使用默认分辨率 {_globalTargetResolution}");
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
catch (System.Exception e)
|
|
64
66
|
{
|
|
65
67
|
Debug.LogError($"[XDSDK] 读取配置文件失败: {e.Message}");
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
}
|
|
@@ -86,5 +86,26 @@ namespace XD.SDK.Common
|
|
|
86
86
|
{
|
|
87
87
|
XDGCommonInternal.OpenWebPage(url, callback);
|
|
88
88
|
}
|
|
89
|
+
/// <summary>
|
|
90
|
+
/// 获取包体类型
|
|
91
|
+
/// Tips: 在 PNSDK 环境下不可用
|
|
92
|
+
///
|
|
93
|
+
/// 在 PC 上
|
|
94
|
+
/// 1. 当 Steam SDK 启用时,优先返回 XDGPackageType.PackageTypePCSteam
|
|
95
|
+
/// 2. 当 TapTap 平台启用时,返回 XDGPackageType.PackageTypePCTapTap
|
|
96
|
+
/// 3. 否则返回默认 XDGPackageType.PackageTypePCNormal
|
|
97
|
+
///
|
|
98
|
+
/// 在 Android 上
|
|
99
|
+
/// 如果是 GooglePlay 包体,则返回 XDGPackageType.PackageTypeAndroidGooglePlay
|
|
100
|
+
/// 如果不是则返回 XDGPackageType.PackageTypeAndroidNormal
|
|
101
|
+
///
|
|
102
|
+
/// 在 iOS 上
|
|
103
|
+
/// 固定返回 XDGPackageType.PackageTypeAppStore
|
|
104
|
+
/// </summary>
|
|
105
|
+
/// <returns>包体类型</returns>
|
|
106
|
+
public static string GetPackageType()
|
|
107
|
+
{
|
|
108
|
+
return XDGCommonInternal.GetPackageType();
|
|
109
|
+
}
|
|
89
110
|
}
|
|
90
111
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "com.xd.sdk.common",
|
|
3
3
|
"displayName": "XDGSDK Common",
|
|
4
|
-
"version": "7.2.1-alpha.
|
|
4
|
+
"version": "7.2.1-alpha.4",
|
|
5
5
|
"description": "XDGSDK",
|
|
6
6
|
"unity": "2019.3",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"com.xd.sdk.foundation": "7.2.1-alpha.
|
|
9
|
+
"com.xd.sdk.foundation": "7.2.1-alpha.4"
|
|
10
10
|
}
|
|
11
11
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 082d115a60bee4bccb8d6de4cdafc8ee
|
|
3
|
-
PluginImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
iconMap: {}
|
|
7
|
-
executionOrder: {}
|
|
8
|
-
defineConstraints: []
|
|
9
|
-
isPreloaded: 0
|
|
10
|
-
isOverridable: 1
|
|
11
|
-
isExplicitlyReferenced: 0
|
|
12
|
-
validateReferences: 1
|
|
13
|
-
platformData:
|
|
14
|
-
- first:
|
|
15
|
-
Android: Android
|
|
16
|
-
second:
|
|
17
|
-
enabled: 1
|
|
18
|
-
settings: {}
|
|
19
|
-
- first:
|
|
20
|
-
Any:
|
|
21
|
-
second:
|
|
22
|
-
enabled: 0
|
|
23
|
-
settings: {}
|
|
24
|
-
- first:
|
|
25
|
-
Editor: Editor
|
|
26
|
-
second:
|
|
27
|
-
enabled: 0
|
|
28
|
-
settings:
|
|
29
|
-
DefaultValueInitialized: true
|
|
30
|
-
userData:
|
|
31
|
-
assetBundleName:
|
|
32
|
-
assetBundleVariant:
|
|
File without changes
|
|
File without changes
|