com.typhoon.unitysdk 1.1.14 → 1.1.16
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/CHANGELOG.md +13 -1
- package/Runtime/GamePauser.cs +84 -0
- package/Runtime/GamePauser.cs.meta +11 -0
- package/Runtime/HandleOnAppFocus.cs +14 -0
- package/Runtime/HandleOnAppFocus.cs.meta +11 -0
- package/Runtime/MiniGameLifecycle.cs +93 -0
- package/Runtime/MiniGameLifecycle.cs.meta +11 -0
- package/Runtime/Paths.cs +1 -0
- package/Runtime/SDKInteractiveUI.cs +12 -12
- package/Runtime/SdkLite.cs +18 -3
- package/Runtime/SdkTestInUnity.cs +20 -63
- package/Sources~/Package/MiniGame.unitypackage +0 -0
- package/Sources~/Package//345/270/270/347/224/250/346/211/223/345/214/205/351/205/215/347/275/256.unitypackage +0 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
# 更新日志
|
|
2
|
+
## [1.1.16] - 2025-08-12
|
|
3
|
+
|
|
4
|
+
### 新增
|
|
5
|
+
* 微游渠道新增生命周期函数以及默认相关处理方案,通用性解决广告播放时游戏端仍然在跑的问题
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## [1.1.15] - 2025-08-09
|
|
9
|
+
|
|
10
|
+
### 修复
|
|
11
|
+
* 修复测试参数bug
|
|
12
|
+
|
|
13
|
+
|
|
2
14
|
## [1.1.14] - 2025-08-09
|
|
3
15
|
|
|
4
|
-
### 修复
|
|
16
|
+
### 修复
|
|
5
17
|
* 修复sdktestunity构建时间不对时的bug
|
|
6
18
|
|
|
7
19
|
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
/// <summary>
|
|
5
|
+
/// 游戏暂停器
|
|
6
|
+
/// </summary>
|
|
7
|
+
public class GamePauser
|
|
8
|
+
{
|
|
9
|
+
public HashSet<string> TagsHash = new HashSet<string>();
|
|
10
|
+
private bool IsPaused { get; set; } = false;
|
|
11
|
+
private float TimeScaleBeforePause { get; set; }
|
|
12
|
+
private bool AudioListenerStateBeforePause { get; set; }
|
|
13
|
+
|
|
14
|
+
/// <summary>
|
|
15
|
+
/// 新增暂停标记
|
|
16
|
+
/// </summary>
|
|
17
|
+
/// <param name="tag"></param>
|
|
18
|
+
public void AddPauseTag(string tag)
|
|
19
|
+
{
|
|
20
|
+
if (TagsHash.Contains(tag))
|
|
21
|
+
{
|
|
22
|
+
//已经存在相关标记,不处理
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var success = TagsHash.Add(tag);
|
|
27
|
+
if (success)
|
|
28
|
+
{
|
|
29
|
+
OnTagsChanged();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// <summary>
|
|
34
|
+
/// 移除暂停标记
|
|
35
|
+
/// </summary>
|
|
36
|
+
public void RemovePauseTag(string tag)
|
|
37
|
+
{
|
|
38
|
+
var success = TagsHash.Remove(tag);
|
|
39
|
+
if (success)
|
|
40
|
+
{
|
|
41
|
+
OnTagsChanged();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private void OnTagsChanged()
|
|
46
|
+
{
|
|
47
|
+
if (TagsHash.Count > 0)
|
|
48
|
+
{
|
|
49
|
+
//暂停
|
|
50
|
+
Pause();
|
|
51
|
+
}
|
|
52
|
+
else
|
|
53
|
+
{
|
|
54
|
+
//恢复
|
|
55
|
+
Resume();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private void Pause()
|
|
60
|
+
{
|
|
61
|
+
if (IsPaused)
|
|
62
|
+
{
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
IsPaused = true;
|
|
67
|
+
TimeScaleBeforePause = Time.timeScale;
|
|
68
|
+
AudioListenerStateBeforePause = AudioListener.pause;
|
|
69
|
+
Time.timeScale = 0f;
|
|
70
|
+
AudioListener.pause = true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private void Resume()
|
|
74
|
+
{
|
|
75
|
+
if (!IsPaused)
|
|
76
|
+
{
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
IsPaused = false;
|
|
81
|
+
Time.timeScale = TimeScaleBeforePause;
|
|
82
|
+
AudioListener.pause = AudioListenerStateBeforePause;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
namespace TyphoonUnitySDK
|
|
2
|
+
{
|
|
3
|
+
public interface IMiniGameLifecycle
|
|
4
|
+
{
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// 激励视频播放前
|
|
7
|
+
/// </summary>
|
|
8
|
+
void OnVideoBeforePlay();
|
|
9
|
+
|
|
10
|
+
/// <summary>
|
|
11
|
+
/// 激励视频处理完毕时
|
|
12
|
+
/// </summary>
|
|
13
|
+
void OnVideoComplete(bool isSuccess);
|
|
14
|
+
|
|
15
|
+
/// <summary>
|
|
16
|
+
/// 插页播放前
|
|
17
|
+
/// </summary>
|
|
18
|
+
void OnIntersBeforePlay();
|
|
19
|
+
|
|
20
|
+
/// <summary>
|
|
21
|
+
/// 插页处理完毕时
|
|
22
|
+
/// </summary>
|
|
23
|
+
void OnIntersComplete(bool isSuccess);
|
|
24
|
+
|
|
25
|
+
/// <summary>
|
|
26
|
+
/// 焦点变化时
|
|
27
|
+
/// </summary>
|
|
28
|
+
void OnFocus(bool hasFocus);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// <summary>
|
|
32
|
+
/// 微游生命周期
|
|
33
|
+
/// </summary>
|
|
34
|
+
public class MiniGameLifecycle : IMiniGameLifecycle
|
|
35
|
+
{
|
|
36
|
+
public GamePauser GamePauser = new GamePauser();
|
|
37
|
+
private const string TAG_VIDEO = "video";
|
|
38
|
+
private const string TAG_INTERS = "inters";
|
|
39
|
+
private const string TAG_FOCUS = "focus";
|
|
40
|
+
|
|
41
|
+
/// <summary>
|
|
42
|
+
/// 激励视频播放前
|
|
43
|
+
/// </summary>
|
|
44
|
+
public virtual void OnVideoBeforePlay()
|
|
45
|
+
{
|
|
46
|
+
SdkDebug.Log("[MiniGameLifecycle] OnVideoBeforePlay");
|
|
47
|
+
GamePauser.AddPauseTag(TAG_VIDEO);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/// <summary>
|
|
51
|
+
/// 激励视频处理完毕时
|
|
52
|
+
/// </summary>
|
|
53
|
+
public virtual void OnVideoComplete(bool isSuccess)
|
|
54
|
+
{
|
|
55
|
+
SdkDebug.Log($"[MiniGameLifecycle] OnVideoComplete isSuccess = {isSuccess}");
|
|
56
|
+
GamePauser.RemovePauseTag(TAG_VIDEO);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/// <summary>
|
|
60
|
+
/// 插页播放前
|
|
61
|
+
/// </summary>
|
|
62
|
+
public virtual void OnIntersBeforePlay()
|
|
63
|
+
{
|
|
64
|
+
SdkDebug.Log("[MiniGameLifecycle] OnVideoComplete");
|
|
65
|
+
GamePauser.AddPauseTag(TAG_INTERS);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/// <summary>
|
|
69
|
+
/// 插页处理完毕时
|
|
70
|
+
/// </summary>
|
|
71
|
+
public virtual void OnIntersComplete(bool isSuccess)
|
|
72
|
+
{
|
|
73
|
+
SdkDebug.Log($"[MiniGameLifecycle] OnVideoComplete isSuccess = {isSuccess}");
|
|
74
|
+
GamePauser.RemovePauseTag(TAG_INTERS);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/// <summary>
|
|
78
|
+
/// 焦点变化时
|
|
79
|
+
/// </summary>
|
|
80
|
+
public virtual void OnFocus(bool hasFocus)
|
|
81
|
+
{
|
|
82
|
+
SdkDebug.Log($"[MiniGameLifecycle] OnFocus hasFocus = {hasFocus}");
|
|
83
|
+
if (hasFocus)
|
|
84
|
+
{
|
|
85
|
+
GamePauser.RemovePauseTag(TAG_FOCUS);
|
|
86
|
+
}
|
|
87
|
+
else
|
|
88
|
+
{
|
|
89
|
+
GamePauser.AddPauseTag(TAG_FOCUS);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
package/Runtime/Paths.cs
CHANGED
|
@@ -18,7 +18,18 @@ namespace TyphoonUnitySDK
|
|
|
18
18
|
public static Color Blue = new Color(0.02f, 0.49f, 0.84f, 0.8f);
|
|
19
19
|
public static Color DarkBlue = new Color(0.05f, 0.33f, 0.61f, 1f);
|
|
20
20
|
|
|
21
|
-
public static float HOLD_TIME
|
|
21
|
+
public static float HOLD_TIME
|
|
22
|
+
{
|
|
23
|
+
get
|
|
24
|
+
{
|
|
25
|
+
if (SdkTestInUnity.HasInstance())
|
|
26
|
+
{
|
|
27
|
+
return SdkTestInUnity.Instance.InteractiveHoldCloseTime;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return 1.2f;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
22
33
|
|
|
23
34
|
public static string PathRoot => RuntimeUtil.GetPathRoot();
|
|
24
35
|
|
|
@@ -229,7 +240,6 @@ namespace TyphoonUnitySDK
|
|
|
229
240
|
DrawViewTxtLabel(rectClose, "关闭");
|
|
230
241
|
//悬停/关闭
|
|
231
242
|
HoldHide(rectClose, ref HoldTime, Hide);
|
|
232
|
-
|
|
233
243
|
var rectTitle = view;
|
|
234
244
|
rectTitle.width = 300;
|
|
235
245
|
rectTitle.height = 66;
|
|
@@ -292,15 +302,12 @@ namespace TyphoonUnitySDK
|
|
|
292
302
|
var process = 1 - Mathf.Clamp01((CloseTime - Time.realtimeSinceStartup) / DURATION);
|
|
293
303
|
var center = Vector2.Lerp(startCenter, endCenter, process);
|
|
294
304
|
rectToast.center = center;
|
|
295
|
-
|
|
296
305
|
var rectOutline = rectToast;
|
|
297
306
|
rectOutline.width += 8;
|
|
298
307
|
rectOutline.height += 8;
|
|
299
308
|
rectOutline.center = rectToast.center;
|
|
300
|
-
|
|
301
309
|
EditorGUI.DrawRect(rectOutline, DarkBlue);
|
|
302
310
|
EditorGUI.DrawRect(rectToast, Blue);
|
|
303
|
-
|
|
304
311
|
_labelStyle.fontSize = (int)(Mathf.Min(rectToast.width * 0.5f / Length, 48));
|
|
305
312
|
GUI.Label(rectToast, $"弹出插页:{Scene}", _labelStyle);
|
|
306
313
|
if (Time.realtimeSinceStartup > CloseTime)
|
|
@@ -360,29 +367,24 @@ namespace TyphoonUnitySDK
|
|
|
360
367
|
rectYes.width = 346;
|
|
361
368
|
rectYes.height = 80;
|
|
362
369
|
rectYes.center = rect.center;
|
|
363
|
-
|
|
364
370
|
var rectNo = rectYes;
|
|
365
371
|
rectNo.y = rectYes.yMax;
|
|
366
372
|
rectNo.y += 40;
|
|
367
|
-
|
|
368
373
|
var rectTitle = rectYes;
|
|
369
374
|
rectTitle.y = rectYes.yMin - rectTitle.height;
|
|
370
375
|
rectTitle.y -= 40;
|
|
371
376
|
var center = rectTitle.center;
|
|
372
377
|
rectTitle.width = 500;
|
|
373
378
|
rectTitle.center = center;
|
|
374
|
-
|
|
375
379
|
var rectBg = new Rect();
|
|
376
380
|
rectBg.width = rectTitle.width;
|
|
377
381
|
rectBg.height = rectNo.yMax - rectTitle.yMin;
|
|
378
382
|
rectBg.width += 20;
|
|
379
383
|
rectBg.height += 20;
|
|
380
384
|
rectBg.center = rect.center;
|
|
381
|
-
|
|
382
385
|
EditorGUI.DrawRect(rect, Color.black * 0.7f);
|
|
383
386
|
EditorGUI.DrawRect(rectBg, Blue);
|
|
384
387
|
|
|
385
|
-
|
|
386
388
|
//失败返回
|
|
387
389
|
DrawViewTxtLabel(rectYes, "成功返回");
|
|
388
390
|
DrawViewTxtLabel(rectNo, "失败返回");
|
|
@@ -552,7 +554,6 @@ namespace TyphoonUnitySDK
|
|
|
552
554
|
rectClose.y += 10;
|
|
553
555
|
DrawViewTxtLabel(rectClose, "关闭");
|
|
554
556
|
HoldHide(rectClose, ref HoldTime, Hide);
|
|
555
|
-
|
|
556
557
|
var rectTitle = imageRect;
|
|
557
558
|
rectTitle.width = 400;
|
|
558
559
|
rectTitle.height = 128;
|
|
@@ -572,7 +573,6 @@ namespace TyphoonUnitySDK
|
|
|
572
573
|
private void OnGUI()
|
|
573
574
|
{
|
|
574
575
|
#if UNITY_EDITOR
|
|
575
|
-
|
|
576
576
|
var mode = GetMode();
|
|
577
577
|
var rect = new Rect(0, 0, Screen.width, Screen.height);
|
|
578
578
|
Banner.OnGUI(rect, mode);
|
package/Runtime/SdkLite.cs
CHANGED
|
@@ -37,6 +37,24 @@ namespace TyphoonUnitySDK
|
|
|
37
37
|
OnHide?.Invoke();
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
#region 生命周期
|
|
41
|
+
|
|
42
|
+
/// <summary>
|
|
43
|
+
/// 微游渠道生命周期相关函数
|
|
44
|
+
/// </summary>
|
|
45
|
+
public static IMiniGameLifecycle MiniGameLifecycle { get; set; }
|
|
46
|
+
|
|
47
|
+
/// <summary>
|
|
48
|
+
/// 覆盖微游生命周期
|
|
49
|
+
/// </summary>
|
|
50
|
+
/// <param name="lifecycle"></param>
|
|
51
|
+
public static void OverrideMiniGameLifecycle(IMiniGameLifecycle lifecycle)
|
|
52
|
+
{
|
|
53
|
+
MiniGameLifecycle = lifecycle;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#endregion
|
|
57
|
+
|
|
40
58
|
/*绑定SDK实例*/
|
|
41
59
|
public static Dictionary<AppChannel, string> SDKBindings = new Dictionary<AppChannel, string>
|
|
42
60
|
{
|
|
@@ -73,7 +91,6 @@ namespace TyphoonUnitySDK
|
|
|
73
91
|
}
|
|
74
92
|
}
|
|
75
93
|
|
|
76
|
-
|
|
77
94
|
protected override void Init()
|
|
78
95
|
{
|
|
79
96
|
base.Init();
|
|
@@ -114,7 +131,6 @@ namespace TyphoonUnitySDK
|
|
|
114
131
|
}
|
|
115
132
|
}
|
|
116
133
|
|
|
117
|
-
|
|
118
134
|
private IOnPayCallback CreateOnPayCallbackInstance()
|
|
119
135
|
{
|
|
120
136
|
var type = GetType(PAY_CALL_BACK_CLASS_NAME);
|
|
@@ -864,7 +880,6 @@ namespace TyphoonUnitySDK
|
|
|
864
880
|
|
|
865
881
|
#endregion
|
|
866
882
|
|
|
867
|
-
|
|
868
883
|
#region 事件上报
|
|
869
884
|
|
|
870
885
|
/// <summary>
|
|
@@ -89,80 +89,37 @@ public class SdkTestInUnity : ScriptableObject
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
// private static SdkTestInUnity _instance = null;
|
|
93
|
-
//
|
|
94
|
-
// public static SdkTestInUnity Instance
|
|
95
|
-
// {
|
|
96
|
-
// get
|
|
97
|
-
// {
|
|
98
|
-
// #if UNITY_EDITOR
|
|
99
|
-
// if (_instance == null)
|
|
100
|
-
// {
|
|
101
|
-
// _instance = AssetDatabase.LoadAssetAtPath<SdkTestInUnity>(ASSET_PATH);
|
|
102
|
-
// if (_instance == null)
|
|
103
|
-
// {
|
|
104
|
-
// _instance = CreateInstance<SdkTestInUnity>();
|
|
105
|
-
// var folder = Path.GetDirectoryName(ASSET_PATH);
|
|
106
|
-
// if (!Directory.Exists(folder))
|
|
107
|
-
// {
|
|
108
|
-
// Directory.CreateDirectory(folder);
|
|
109
|
-
// AssetDatabase.Refresh();
|
|
110
|
-
// }
|
|
111
|
-
//
|
|
112
|
-
// AssetDatabase.CreateAsset(_instance, ASSET_PATH);
|
|
113
|
-
// AssetDatabase.Refresh();
|
|
114
|
-
// }
|
|
115
|
-
// }
|
|
116
|
-
// #endif
|
|
117
|
-
// return _instance;
|
|
118
|
-
// }
|
|
119
|
-
// }
|
|
120
|
-
|
|
121
92
|
private static SdkTestInUnity _instance = null;
|
|
122
|
-
private static
|
|
93
|
+
private static object _lock = new object();
|
|
94
|
+
public static bool HasInstance() => _instance != null;
|
|
123
95
|
|
|
124
96
|
public static SdkTestInUnity Instance
|
|
125
97
|
{
|
|
126
98
|
get
|
|
127
99
|
{
|
|
128
100
|
#if UNITY_EDITOR
|
|
129
|
-
if (
|
|
101
|
+
if (_instance == null)
|
|
130
102
|
{
|
|
131
|
-
|
|
132
|
-
|
|
103
|
+
_instance = AssetDatabase.LoadAssetAtPath<SdkTestInUnity>(ASSET_PATH);
|
|
104
|
+
lock (_lock)
|
|
105
|
+
{
|
|
106
|
+
if (_instance == null)
|
|
107
|
+
{
|
|
108
|
+
_instance = CreateInstance<SdkTestInUnity>();
|
|
109
|
+
var folder = Path.GetDirectoryName(ASSET_PATH);
|
|
110
|
+
if (!Directory.Exists(folder))
|
|
111
|
+
{
|
|
112
|
+
Directory.CreateDirectory(folder);
|
|
113
|
+
AssetDatabase.Refresh();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
AssetDatabase.CreateAsset(_instance, ASSET_PATH);
|
|
117
|
+
AssetDatabase.Refresh();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
133
120
|
}
|
|
134
121
|
#endif
|
|
135
122
|
return _instance;
|
|
136
123
|
}
|
|
137
124
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
#if UNITY_EDITOR
|
|
141
|
-
private static void InitializeInstance()
|
|
142
|
-
{
|
|
143
|
-
if (_instance != null) return;
|
|
144
|
-
_instance = AssetDatabase.LoadAssetAtPath<SdkTestInUnity>(ASSET_PATH);
|
|
145
|
-
if (_instance == null)
|
|
146
|
-
{
|
|
147
|
-
_instance = CreateInstance<SdkTestInUnity>();
|
|
148
|
-
var folder = Path.GetDirectoryName(ASSET_PATH);
|
|
149
|
-
if (!Directory.Exists(folder))
|
|
150
|
-
{
|
|
151
|
-
Directory.CreateDirectory(folder);
|
|
152
|
-
AssetDatabase.Refresh();
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
AssetDatabase.CreateAsset(_instance, ASSET_PATH);
|
|
156
|
-
AssetDatabase.SaveAssets();
|
|
157
|
-
AssetDatabase.Refresh();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
[InitializeOnLoadMethod]
|
|
162
|
-
private static void EditorInitialize()
|
|
163
|
-
{
|
|
164
|
-
// 确保在编辑器加载时初始化,但不会在静态构造函数里触发
|
|
165
|
-
InitializeInstance();
|
|
166
|
-
}
|
|
167
|
-
#endif
|
|
168
125
|
}
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"com.typhoon.unitysdk","displayName":"typhoon unity sdk","version":"1.1.
|
|
1
|
+
{"name":"com.typhoon.unitysdk","displayName":"typhoon unity sdk","version":"1.1.16","description":"","unity":"2018.1","type":"tool","hideInEditor":false,"author":{"name":"Jan Zhang","email":"","url":""},"changelogUrl":"","documentationUrl":"","keywords":["typhoon"],"license":"","licensesUrl":"","customDependencies":[{"PackageName":"com.unity.nuget.newtonsoft-json","Value":"2.0.0"}],"version_log":"## [1.1.16] - 2025-08-12\r\n\r\n### 新增\n* 微游渠道新增生命周期函数以及默认相关处理方案,通用性解决广告播放时游戏端仍然在跑的问题\r\n\r\n","major_flag":false,"write_time_stamp":1755001382000,"others":{"items":[]},"dependencies":{"com.unity.nuget.newtonsoft-json":"2.0.0"}}
|