com.typhoon.unitysdk 1.1.15 → 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 +7 -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/SdkLite.cs +18 -3
- 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
|
@@ -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
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>
|
|
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"}}
|