com.typhoon.unitysdk 1.1.23 → 1.1.25

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.
@@ -0,0 +1,100 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.IO;
4
+ using UnityEditor;
5
+ using UnityEngine;
6
+
7
+ namespace TyphoonUnitySDK
8
+ {
9
+ public static class YandexGamesConfigGUIDrawer
10
+ {
11
+ public static Dictionary<string, Func<YandexGamesConfig, bool>> OverrideDrawGUIFunc =
12
+ new Dictionary<string, Func<YandexGamesConfig, bool>>()
13
+ {
14
+ { "m_Script", DrawProperty_m_Script },
15
+ };
16
+
17
+
18
+ private static bool DrawProperty_m_Script(YandexGamesConfig arg)
19
+ {
20
+ var tmpEnable = GUI.enabled;
21
+ GUI.enabled = true;
22
+ GUILayout.Space(6);
23
+ GUIDrawer.DrawKeynotes("①支持Unity 2021.3.18+ , 2022.3+ , 2023.2+ , Unity 6");
24
+ GUIDrawer.DrawKeynotes("②剔除第三方SDK,避免与渠道冲突或不兼容");
25
+ GUILayout.Space(6);
26
+ GUI.enabled = tmpEnable;
27
+ return true;
28
+ }
29
+
30
+
31
+ /*绘制GUI*/
32
+ public static void DrawGUI()
33
+ {
34
+ var config = YandexGamesConfig.Default;
35
+ GUIDrawer.DrawProperty(config, (property) =>
36
+ {
37
+ if (OverrideDrawGUIFunc.TryGetValue(property, out var match))
38
+ {
39
+ return match.Invoke(config);
40
+ }
41
+
42
+ return false;
43
+ });
44
+ }
45
+ }
46
+
47
+ public class YandexGamesConfig : ScriptableObject
48
+ {
49
+ private static string ConfigPath = "Assets/Typhoon_Gen/TyphoonSDK/Editor/YandexGamesConfig.asset";
50
+
51
+ private static YandexGamesConfig _instance = null;
52
+
53
+ public static YandexGamesConfig Default
54
+ {
55
+ get
56
+ {
57
+ if (_instance == null)
58
+ {
59
+ _instance = AssetDatabase.LoadAssetAtPath<YandexGamesConfig>(ConfigPath);
60
+ }
61
+
62
+ if (_instance == null)
63
+ {
64
+ _instance = CreateInstance<YandexGamesConfig>();
65
+ var folder = Path.GetDirectoryName(ConfigPath);
66
+ if (!Directory.Exists(folder))
67
+ {
68
+ Directory.CreateDirectory(folder);
69
+ AssetDatabase.Refresh();
70
+ }
71
+
72
+ AssetDatabase.CreateAsset(_instance, ConfigPath);
73
+ }
74
+
75
+ return _instance;
76
+ }
77
+ }
78
+
79
+
80
+ [LabelOverride("插页广告展示最小间隔(秒)(>=0)", 220)]
81
+ public int IntersInterval = 45;
82
+
83
+ [LabelOverride("激励视频播放后跳过下一次插页广告", 220)]
84
+ public bool SkipIntersAfterShowRewardFlag = true;
85
+
86
+ [LabelOverride("自定义导出目录名(可选)", 220)]
87
+ public string ExportProjName = string.Empty;
88
+
89
+ public void Save()
90
+ {
91
+ EditorUtility.SetDirty(this);
92
+ AssetDatabase.SaveAssets();
93
+ }
94
+
95
+ public void SaveConfig()
96
+ {
97
+ Save();
98
+ }
99
+ }
100
+ }
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: 5945480f0f58ae842a093a2536428362
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 71f11db4d01d81d4892801f511150fec
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -65,9 +65,17 @@ namespace TyphoonUnitySDK
65
65
  /// 喜中游
66
66
  /// </summary>
67
67
  XiZhongYou = 12,
68
+
68
69
  /// <summary>
69
70
  /// 华为鸿蒙
70
71
  /// </summary>
71
72
  HuaweiHarmony = 13,
73
+
74
+
75
+ /// <summary>
76
+ /// YandexGames
77
+ /// </summary>
78
+ YandexGames = 14,
79
+
72
80
  }
73
81
  }
@@ -346,5 +346,12 @@ namespace TyphoonUnitySDK
346
346
  }
347
347
 
348
348
  #endregion
349
+
350
+ public virtual SystemLanguage GetSystemLanguage()
351
+ {
352
+ SdkDebug.Log(
353
+ $"[BaseSdk] GetSystemLanguage... return Application.systemLanguage:{Application.systemLanguage}");
354
+ return Application.systemLanguage;
355
+ }
349
356
  }
350
357
  }
@@ -1,5 +1,7 @@
1
1
  using System.Collections.Generic;
2
+ using System.Linq;
2
3
  using UnityEngine;
4
+ using UnityEngine.EventSystems;
3
5
 
4
6
  /// <summary>
5
7
  /// 游戏暂停器
@@ -11,6 +13,8 @@ public class GamePauser
11
13
  private float TimeScaleBeforePause { get; set; }
12
14
  private bool AudioListenerStateBeforePause { get; set; }
13
15
 
16
+ private Dictionary<EventSystem, bool> DictEventSystemState { get; set; }
17
+
14
18
  /// <summary>
15
19
  /// 新增暂停标记
16
20
  /// </summary>
@@ -66,8 +70,11 @@ public class GamePauser
66
70
  IsPaused = true;
67
71
  TimeScaleBeforePause = Time.timeScale;
68
72
  AudioListenerStateBeforePause = AudioListener.pause;
73
+ var systems = Object.FindObjectsByType<EventSystem>(
74
+ FindObjectsSortMode.None);
69
75
  Time.timeScale = 0f;
70
76
  AudioListener.pause = true;
77
+ DictEventSystemState = systems.ToDictionary(e => e, e => e.enabled);
71
78
  }
72
79
 
73
80
  private void Resume()
@@ -80,5 +87,14 @@ public class GamePauser
80
87
  IsPaused = false;
81
88
  Time.timeScale = TimeScaleBeforePause;
82
89
  AudioListener.pause = AudioListenerStateBeforePause;
90
+ foreach (var pair in DictEventSystemState)
91
+ {
92
+ if (pair.Key == null)
93
+ {
94
+ continue;
95
+ }
96
+
97
+ pair.Key.enabled = pair.Value;
98
+ }
83
99
  }
84
100
  }
@@ -1,5 +1,6 @@
1
1
  using System;
2
2
  using System.Collections.Generic;
3
+ using UnityEngine;
3
4
 
4
5
  namespace TyphoonUnitySDK
5
6
  {
@@ -8,7 +9,7 @@ namespace TyphoonUnitySDK
8
9
  /// </summary>
9
10
  public interface ISdk : IOnCreate, IInitSdk, ILogin, IExitGame, IBannerAD, IVideoAD, IIntersAD, IFloatIconAD,
10
11
  INativeAD, IRecordGame, IHttpGet, IHttpPost, ISideBarReturn, IShowToast, ITrack, IQuitGameWithKeep,
11
- IRequestProductInfosAsync, IPay
12
+ IRequestProductInfosAsync, IPay,IGetSystemLanguage
12
13
  {
13
14
  }
14
15
 
@@ -191,7 +192,6 @@ namespace TyphoonUnitySDK
191
192
 
192
193
  #endregion
193
194
 
194
-
195
195
  #region ShowToast
196
196
 
197
197
  /// <summary>
@@ -213,7 +213,6 @@ namespace TyphoonUnitySDK
213
213
 
214
214
  #endregion
215
215
 
216
-
217
216
  #region 退出挽留
218
217
 
219
218
  public interface IQuitGameWithKeep
@@ -259,4 +258,13 @@ namespace TyphoonUnitySDK
259
258
  }
260
259
 
261
260
  #endregion
261
+
262
+ #region 获取系统语言
263
+
264
+ public interface IGetSystemLanguage
265
+ {
266
+ SystemLanguage GetSystemLanguage();
267
+ }
268
+
269
+ #endregion
262
270
  }
@@ -37,6 +37,7 @@ namespace TyphoonUnitySDK
37
37
  OnHide?.Invoke();
38
38
  }
39
39
 
40
+
40
41
  #region 生命周期
41
42
 
42
43
  /// <summary>
@@ -53,6 +54,19 @@ namespace TyphoonUnitySDK
53
54
  MiniGameLifecycle = lifecycle;
54
55
  }
55
56
 
57
+ /// <summary>
58
+ /// YandexGames渠道生命周期相关函数
59
+ /// </summary>
60
+ public static IYandexGamesLifecycle YandexGamesLifecycle { get; set; }
61
+
62
+ /// <summary>
63
+ /// 覆盖YandexGames生命周期
64
+ /// </summary>
65
+ public static void OverrideYandexGamesLifecycle(IYandexGamesLifecycle lifecycle)
66
+ {
67
+ YandexGamesLifecycle = lifecycle;
68
+ }
69
+
56
70
  #endregion
57
71
 
58
72
  /*绑定SDK实例*/
@@ -69,6 +83,7 @@ namespace TyphoonUnitySDK
69
83
  { AppChannel.MiniGame, "TyphoonUnitySDK.MiniGameSdk" }, //微游
70
84
  { AppChannel.XiZhongYou, "TyphoonUnitySDK.XiZhongYouSdk" }, //喜中游
71
85
  { AppChannel.HuaweiHarmony, "TyphoonUnitySDK.HuaweiHarmonySdk" }, //华为鸿蒙
86
+ { AppChannel.YandexGames, "TyphoonUnitySDK.YandexGamesSdk" }, //YandexGames
72
87
  };
73
88
 
74
89
  //支付回调类名
@@ -960,5 +975,22 @@ namespace TyphoonUnitySDK
960
975
  }
961
976
 
962
977
  #endregion
978
+
979
+ #region 系统语言
980
+
981
+ public virtual SystemLanguage GetSystemLanguage()
982
+ {
983
+ #if UNITY_EDITOR
984
+ if (SdkTestInUnity.Instance.UseTestSystemLanguageFlag)
985
+ {
986
+ return SdkTestInUnity.Instance.SystemLanguage;
987
+ }
988
+
989
+ return Application.systemLanguage;
990
+ #endif
991
+ return _sdk.GetSystemLanguage();
992
+ }
993
+
994
+ #endregion
963
995
  }
964
996
  }
@@ -12,6 +12,13 @@ using UnityEditor;
12
12
  public class SdkTestInUnity : ScriptableObject
13
13
  {
14
14
  private const string ASSET_PATH = "Assets/Typhoon_Gen/TyphoonSDK/Editor/SdkTestInUnity.asset";
15
+
16
+ [Header("系统语言")]
17
+ [LabelOverride("使用测试参数")]
18
+ public bool UseTestSystemLanguageFlag = false;
19
+ [LabelOverride("系统语言")]
20
+ public SystemLanguage SystemLanguage = SystemLanguage.English;
21
+
15
22
  [Header("登录")]
16
23
  [LabelOverride("登录回调")]
17
24
  public bool LoginResult = true;
@@ -0,0 +1,41 @@
1
+ namespace TyphoonUnitySDK
2
+ {
3
+ public interface IYandexGamesLifecycle
4
+ {
5
+ void OnPauseGame(bool isPaused);
6
+ void OnCloseAnyAdv();
7
+ void OnOpenAnyAdv();
8
+ }
9
+
10
+ /// <summary>
11
+ /// yandex games 生命周期
12
+ /// </summary>
13
+ public class YandexGamesLifecycle : IYandexGamesLifecycle
14
+ {
15
+ private GamePauser GamePauser { get; } = new GamePauser();
16
+ private const string TAG_ON_PAUSE_GAME = "TAG_ON_PAUSE_GAME";
17
+ private const string TAG_ANY_ADV = "TAG_ANY_ADV";
18
+
19
+ public void OnPauseGame(bool isPaused)
20
+ {
21
+ if (isPaused)
22
+ {
23
+ GamePauser.AddPauseTag(TAG_ON_PAUSE_GAME);
24
+ }
25
+ else
26
+ {
27
+ GamePauser.RemovePauseTag(TAG_ON_PAUSE_GAME);
28
+ }
29
+ }
30
+
31
+ public void OnCloseAnyAdv()
32
+ {
33
+ GamePauser.RemovePauseTag(TAG_ANY_ADV);
34
+ }
35
+
36
+ public void OnOpenAnyAdv()
37
+ {
38
+ GamePauser.AddPauseTag(TAG_ANY_ADV);
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 3b69b22c966057748b04dfed8350ee7c
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: