com.typhoon.unitysdk 1.0.34 → 1.0.36

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.
Files changed (49) hide show
  1. package/Editor/ApplyTool.cs +42 -8
  2. package/Editor/ExportModule.cs +23 -0
  3. package/Editor/GUIDrawer.cs +38 -0
  4. package/Editor/MD5Tool.cs +53 -0
  5. package/Editor/MD5Tool.cs.meta +11 -0
  6. package/Editor/Orientation.cs +18 -0
  7. package/Editor/Orientation.cs.meta +11 -0
  8. package/Editor/PluginModuleInstaller.cs +452 -0
  9. package/Editor/PluginModuleInstaller.cs.meta +11 -0
  10. package/Editor/PreferencesWindow.cs +1 -1
  11. package/Editor/PublishProcess.cs +5 -4
  12. package/Editor/PublishSetting.cs +3 -0
  13. package/Editor/PublishSettingGUIDrawer.cs +20 -2
  14. package/Editor/PublishTool.cs +3 -3
  15. package/Editor/PublishWindow.cs +2 -4
  16. package/Editor/UniEditor.cs +249 -13
  17. package/Editor/VivoMiniConfig.cs +436 -0
  18. package/Editor/VivoMiniConfig.cs.meta +11 -0
  19. package/Editor/WxMiniConfig.cs +9 -22
  20. package/Editor/ZipTool.cs +78 -0
  21. package/Editor/ZipTool.cs.meta +11 -0
  22. package/Editor/bats/create-sign.bat +13 -0
  23. package/Editor/bats/create-sign.bat.meta +7 -0
  24. package/Editor/bats.meta +8 -0
  25. package/Editor/dll/AlphaFS.dll +0 -0
  26. package/Editor/dll/AlphaFS.dll.meta +33 -0
  27. package/Editor/dll/XGameDotNetZip.dll +0 -0
  28. package/Editor/dll/XGameDotNetZip.dll.meta +33 -0
  29. package/Editor/dll.meta +8 -0
  30. package/Runtime/AndroidInstance.cs +1 -1
  31. package/Runtime/BaseSdk.cs +64 -0
  32. package/Runtime/Extension.cs +8 -2
  33. package/Runtime/HttpGetSuccessResult.cs +23 -0
  34. package/Runtime/HttpGetSuccessResult.cs.meta +11 -0
  35. package/Runtime/HttpPostSuccessResult.cs +30 -0
  36. package/Runtime/HttpPostSuccessResult.cs.meta +11 -0
  37. package/Runtime/Interface.cs +21 -2
  38. package/Runtime/SDKHttpClient.cs +119 -0
  39. package/Runtime/SDKHttpClient.cs.meta +11 -0
  40. package/Runtime/TyphoonSdk.cs +43 -0
  41. package/Runtime/TyphoonSdkCallback.cs +11 -5
  42. package/Sources~/Package/ChinaAndroid.unitypackage +0 -0
  43. package/Sources~/Package/Douyin.unitypackage +0 -0
  44. package/Sources~/Package/GooglePlay.unitypackage +0 -0
  45. package/Sources~/Package/VivoMini.unitypackage +0 -0
  46. package/Sources~/Package/VivoMini.unitypackage.manifest +261 -0
  47. package/Sources~/Package/WxMini.unitypackage +0 -0
  48. package/Sources~/Package//345/270/270/347/224/250/346/211/223/345/214/205/351/205/215/347/275/256.unitypackage +0 -0
  49. package/package.json +1 -1
@@ -0,0 +1,33 @@
1
+ fileFormatVersion: 2
2
+ guid: 9fb5c535314e7c5469ecbc923f1b27b4
3
+ PluginImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ iconMap: {}
7
+ executionOrder: {}
8
+ defineConstraints: []
9
+ isPreloaded: 0
10
+ isOverridable: 0
11
+ isExplicitlyReferenced: 0
12
+ validateReferences: 1
13
+ platformData:
14
+ - first:
15
+ Any:
16
+ second:
17
+ enabled: 0
18
+ settings: {}
19
+ - first:
20
+ Editor: Editor
21
+ second:
22
+ enabled: 1
23
+ settings:
24
+ DefaultValueInitialized: true
25
+ - first:
26
+ Windows Store Apps: WindowsStoreApps
27
+ second:
28
+ enabled: 0
29
+ settings:
30
+ CPU: AnyCPU
31
+ userData:
32
+ assetBundleName:
33
+ assetBundleVariant:
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: c6540c7e049db634bb0d0bdc3b8d1baa
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -33,7 +33,7 @@ namespace TyphoonUnitySDK
33
33
  {
34
34
  SdkDebug.Log($"CallWithSession {session.MethodName} {session.SendData}");
35
35
  //避免为空
36
- var data = session.SendData.ToJson();
36
+ var data = session.SendData.ToXJson();
37
37
  data = data ?? "";
38
38
  AndroidJavaObject?.Call("receiveSessionFromUnity", session.MethodName, session.SessionId, data);
39
39
  }
@@ -9,15 +9,41 @@ namespace TyphoonUnitySDK
9
9
  /// </summary>
10
10
  public abstract class BaseSdk : ISdk
11
11
  {
12
+ private SDKHttpClient _sdkHttpClient = null;
13
+
14
+ public SDKHttpClient SDKHttpClient
15
+ {
16
+ get
17
+ {
18
+ if (_sdkHttpClient == null)
19
+ {
20
+ _sdkHttpClient = SDKHttpClient.CreateInstance();
21
+ GameObject.DontDestroyOnLoad(_sdkHttpClient.gameObject);
22
+ }
23
+
24
+ return _sdkHttpClient;
25
+ }
26
+ }
27
+
12
28
  /*OnCreate*/
13
29
  public abstract void OnCreate();
14
30
 
31
+ #region 初始化
32
+
15
33
  /*初始化SDK*/
16
34
  public abstract void InitSdk(Action success, Action<string> fail);
17
35
 
36
+ #endregion
37
+
38
+ #region 登录
39
+
18
40
  /*登录*/
19
41
  public abstract void Login(Action success, Action<string> fail);
20
42
 
43
+ #endregion
44
+
45
+ #region 退出游戏
46
+
21
47
  /*是否支持退出游戏*/
22
48
  public virtual bool IsSupportExitGame()
23
49
  {
@@ -29,6 +55,10 @@ namespace TyphoonUnitySDK
29
55
  {
30
56
  }
31
57
 
58
+ #endregion
59
+
60
+ #region Banner
61
+
32
62
  /*展示banner*/
33
63
  public virtual void ShowBanner(string scene, BannerPosition position)
34
64
  {
@@ -39,6 +69,9 @@ namespace TyphoonUnitySDK
39
69
  {
40
70
  }
41
71
 
72
+ #endregion
73
+
74
+ #region 视频广告
42
75
 
43
76
  /*获取激励视频标记*/
44
77
  public virtual bool GetVideoFlag()
@@ -53,11 +86,19 @@ namespace TyphoonUnitySDK
53
86
  success?.Invoke();
54
87
  }
55
88
 
89
+ #endregion
90
+
91
+ #region 插页广告
92
+
56
93
  /*展示插页*/
57
94
  public virtual void ShowInters(string scene)
58
95
  {
59
96
  }
60
97
 
98
+ #endregion
99
+
100
+ #region 悬浮ICON
101
+
61
102
  /*展示悬浮ICON*/
62
103
  public virtual void ShowFloatIcon(string scene, float screenXP, float screenYP)
63
104
  {
@@ -68,6 +109,10 @@ namespace TyphoonUnitySDK
68
109
  {
69
110
  }
70
111
 
112
+ #endregion
113
+
114
+ #region 原生广告
115
+
71
116
  /*展示原生广告*/
72
117
  public virtual void ShowNative(string scene)
73
118
  {
@@ -78,6 +123,7 @@ namespace TyphoonUnitySDK
78
123
  {
79
124
  }
80
125
 
126
+ #endregion
81
127
 
82
128
  #region 录屏分享(抖音小游戏)
83
129
 
@@ -123,5 +169,23 @@ namespace TyphoonUnitySDK
123
169
  }
124
170
 
125
171
  #endregion
172
+
173
+ #region Http请求
174
+
175
+ public virtual void HttpPost(string url, string data, Action<HttpPostSuccessResult> success,
176
+ Action<string> fail,
177
+ Dictionary<string, string> header = null, int timeOut = 60)
178
+ {
179
+ SDKHttpClient.Post(url, data, success, fail, header, timeOut);
180
+ }
181
+
182
+
183
+ public virtual void HttpGet(string url, Action<HttpGetSuccessResult> success, Action<string> fail,
184
+ Dictionary<string, string> header, int timeOut)
185
+ {
186
+ SDKHttpClient.Get(url, success, fail, header, timeOut);
187
+ }
188
+
189
+ #endregion
126
190
  }
127
191
  }
@@ -7,12 +7,18 @@ namespace TyphoonUnitySDK
7
7
  /// </summary>
8
8
  public static partial class Extension
9
9
  {
10
- public static T ToObject<T>(this string json)
10
+ /// <summary>
11
+ /// 从json到object
12
+ /// </summary>
13
+ public static T ToXObject<T>(this string json)
11
14
  {
12
15
  return JsonConvert.DeserializeObject<T>(json);
13
16
  }
14
17
 
15
- public static string ToJson(this object obj)
18
+ /// <summary>
19
+ /// 从object到json
20
+ /// </summary>
21
+ public static string ToXJson(this object obj)
16
22
  {
17
23
  var json = JsonConvert.SerializeObject(obj);
18
24
  return json;
@@ -0,0 +1,23 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using UnityEngine.Scripting;
4
+
5
+ namespace TyphoonUnitySDK
6
+ {
7
+ //成功返回的数据项
8
+ [Preserve]
9
+ [Serializable]
10
+ public struct HttpGetSuccessResult
11
+ {
12
+ public string Data;
13
+ public Dictionary<string, string> Header;
14
+ public long StatusCode;
15
+
16
+ public HttpGetSuccessResult(string data, Dictionary<string, string> header, long statusCode)
17
+ {
18
+ Data = data;
19
+ Header = header;
20
+ StatusCode = statusCode;
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 9cd3a91aaac06f9449cdca07981c1c28
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,30 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using UnityEngine.Scripting;
4
+
5
+ namespace TyphoonUnitySDK
6
+ {
7
+ /// <summary>
8
+ /// post 返回的数据
9
+ /// </summary>
10
+ [Preserve]
11
+ [Serializable]
12
+ public struct HttpPostSuccessResult
13
+ {
14
+ //数据
15
+ public string Data;
16
+
17
+ //请求头
18
+ public Dictionary<string, string> Header;
19
+
20
+ //状态码
21
+ public long StateCode;
22
+
23
+ public HttpPostSuccessResult(string data, Dictionary<string, string> header, long stateCode)
24
+ {
25
+ Data = data;
26
+ Header = header;
27
+ StateCode = stateCode;
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 790b229083df1bc45adda6c4068acccb
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -7,7 +7,7 @@ namespace TyphoonUnitySDK
7
7
  /// SDK全功能接口
8
8
  /// </summary>
9
9
  public interface ISdk : IOnCreate, IInitSdk, ILogin, IExitGame, IBannerAD, IVideoAD, IIntersAD, IFloatIconAD,
10
- INativeAD, IRecordGame
10
+ INativeAD, IRecordGame, IHttpGet, IHttpPost
11
11
  {
12
12
  }
13
13
 
@@ -114,7 +114,6 @@ namespace TyphoonUnitySDK
114
114
 
115
115
  #endregion
116
116
 
117
-
118
117
  #region 录屏分享(抖音小游戏)
119
118
 
120
119
  /*录屏分享(抖音)*/
@@ -145,4 +144,24 @@ namespace TyphoonUnitySDK
145
144
  }
146
145
 
147
146
  #endregion
147
+
148
+ #region Http Post
149
+
150
+ public interface IHttpPost
151
+ {
152
+ void HttpPost(string url, string data, Action<HttpPostSuccessResult> success, Action<string> fail,
153
+ Dictionary<string, string> header, int timeOut);
154
+ }
155
+
156
+ #endregion
157
+
158
+ #region Http Get
159
+
160
+ public interface IHttpGet
161
+ {
162
+ void HttpGet(string url, Action<HttpGetSuccessResult> success, Action<string> fail,
163
+ Dictionary<string, string> header, int timeOut);
164
+ }
165
+
166
+ #endregion
148
167
  }
@@ -0,0 +1,119 @@
1
+ using System;
2
+ using System.Collections;
3
+ using System.Collections.Generic;
4
+ using System.Text;
5
+ using UnityEngine;
6
+ using UnityEngine.Networking;
7
+ using UnityEngine.Scripting;
8
+
9
+ namespace TyphoonUnitySDK
10
+ {
11
+ /// <summary>
12
+ /// 通用HTTP请求
13
+ /// </summary>
14
+ [Preserve]
15
+ public class SDKHttpClient : MonoBehaviour
16
+ {
17
+ public static SDKHttpClient CreateInstance()
18
+ {
19
+ return new GameObject(nameof(SDKHttpClient)).AddComponent<SDKHttpClient>();
20
+ }
21
+
22
+ /// <summary>
23
+ /// post 请求
24
+ /// </summary>
25
+ public void Post(string url, string postData, Action<HttpPostSuccessResult> success, Action<string> fail,
26
+ Dictionary<string, string> header = null, int timeOut = 60)
27
+ {
28
+ //默认走unity 的post
29
+ StartCoroutine(IEUnityHttpPost(url, postData, success, fail, header, timeOut));
30
+ }
31
+
32
+ private IEnumerator IEUnityHttpPost(string url, string data, Action<HttpPostSuccessResult> success,
33
+ Action<string> fail, Dictionary<string, string> header, int timeOut)
34
+ {
35
+ var uri = new Uri(url);
36
+ using (UnityWebRequest www = UnityWebRequest.Post(uri, data))
37
+ {
38
+ byte[] bodyRaw = Encoding.UTF8.GetBytes(data);
39
+ www.uploadHandler = (UploadHandler)new UploadHandlerRaw(bodyRaw);
40
+ www.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
41
+ if (timeOut > 0)
42
+ {
43
+ www.timeout = timeOut;
44
+ }
45
+
46
+ if (header != null)
47
+ {
48
+ foreach (var item in header)
49
+ {
50
+ www.SetRequestHeader(item.Key, item.Value);
51
+ }
52
+ }
53
+
54
+ yield return www.SendWebRequest();
55
+ if (www.isNetworkError || www.isHttpError)
56
+ {
57
+ //错误
58
+ fail?.Invoke(www.error);
59
+ }
60
+ else
61
+ {
62
+ //成功
63
+ var resultData = new HttpPostSuccessResult(www.downloadHandler.text, www.GetResponseHeaders(),
64
+ www.responseCode);
65
+ success?.Invoke(resultData);
66
+ }
67
+ }
68
+ }
69
+
70
+
71
+ /// <summary>
72
+ /// get 请求
73
+ /// </summary>
74
+ public void Get(string url, Action<HttpGetSuccessResult> success, Action<string> fail,
75
+ Dictionary<string, string> header = null, int timeOut = 60)
76
+ {
77
+ StartCoroutine(IEUnityHttpGet(url, success, fail, header, timeOut));
78
+ }
79
+
80
+
81
+ private IEnumerator IEUnityHttpGet(string url, Action<HttpGetSuccessResult> success, Action<string> fail,
82
+ Dictionary<string, string> header, int timeOut)
83
+ {
84
+ var uri = new Uri(url);
85
+ using (UnityWebRequest www = UnityWebRequest.Get(uri))
86
+ {
87
+ //设置请求头
88
+ if (header != null)
89
+ {
90
+ foreach (var kv in header)
91
+ {
92
+ www.SetRequestHeader(kv.Key, kv.Value);
93
+ }
94
+ }
95
+
96
+ //设置超时
97
+ if (timeOut > 0)
98
+ {
99
+ www.timeout = timeOut;
100
+ }
101
+
102
+ www.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
103
+ yield return www.SendWebRequest();
104
+ if (www.isNetworkError || www.isHttpError)
105
+ {
106
+ //失败
107
+ fail?.Invoke(www.error);
108
+ }
109
+ else
110
+ {
111
+ //成功
112
+ var resultData = new HttpGetSuccessResult(www.downloadHandler.text, www.GetResponseHeaders(),
113
+ www.responseCode);
114
+ success?.Invoke(resultData);
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 425fa9b0997a72a4e8772203476d84d4
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -19,10 +19,27 @@ namespace TyphoonUnitySDK
19
19
  { AppChannel.DouyinAndroid, "TyphoonUnitySDK.DouyinSdk" }, //抖音小游戏
20
20
  { AppChannel.DouyinIOS, "TyphoonUnitySDK.DouyinSdk" }, //抖音小游戏
21
21
  { AppChannel.GooglePlay, "TyphoonUnitySDK.GooglePlaySdk" }, //GooglePlay
22
+ { AppChannel.VivoMini, "TyphoonUnitySDK.VivoMiniSdk" }, //Vivo小游戏
22
23
  };
23
24
 
24
25
  private ISdk _sdk;
25
26
 
27
+ private SDKHttpClient _sdkHttpClient = null;
28
+
29
+ public SDKHttpClient SDKHttpClient
30
+ {
31
+ get
32
+ {
33
+ if (_sdkHttpClient == null)
34
+ {
35
+ _sdkHttpClient = SDKHttpClient.CreateInstance();
36
+ GameObject.DontDestroyOnLoad(_sdkHttpClient.gameObject);
37
+ }
38
+
39
+ return _sdkHttpClient;
40
+ }
41
+ }
42
+
26
43
  protected override void Init()
27
44
  {
28
45
  base.Init();
@@ -542,5 +559,31 @@ namespace TyphoonUnitySDK
542
559
  }
543
560
 
544
561
  #endregion
562
+
563
+ #region Http请求
564
+
565
+ public virtual void HttpPost(string url, string data, Action<HttpPostSuccessResult> success,
566
+ Action<string> fail,
567
+ Dictionary<string, string> header = null, int timeOut = 60)
568
+ {
569
+ #if UNITY_EDITOR
570
+ SDKHttpClient.Post(url, data, success, fail, header, timeOut);
571
+ return;
572
+ #endif
573
+ _sdk?.HttpPost(url, data, success, fail, header, timeOut);
574
+ }
575
+
576
+
577
+ public virtual void HttpGet(string url, Action<HttpGetSuccessResult> success, Action<string> fail,
578
+ Dictionary<string, string> header = null, int timeOut = 60)
579
+ {
580
+ #if UNITY_EDITOR
581
+ SDKHttpClient.Get(url, success, fail, header, timeOut);
582
+ return;
583
+ #endif
584
+ _sdk?.HttpGet(url, success, fail, header, timeOut);
585
+ }
586
+
587
+ #endregion
545
588
  }
546
589
  }
@@ -36,12 +36,18 @@ namespace TyphoonUnitySDK
36
36
 
37
37
  public void Update()
38
38
  {
39
- if (Input.GetKeyDown(KeyCode.Escape))
39
+ switch (AppConfig.Channel)
40
40
  {
41
- if (TyphoonSdk.Instance.IsSupportExitGame())
42
- {
43
- TyphoonSdk.Instance.ExitGame();
44
- }
41
+ case AppChannel.ChinaAndroid:
42
+ if (Input.GetKeyDown(KeyCode.Escape))
43
+ {
44
+ if (TyphoonSdk.Instance.IsSupportExitGame())
45
+ {
46
+ TyphoonSdk.Instance.ExitGame();
47
+ }
48
+ }
49
+
50
+ break;
45
51
  }
46
52
  }
47
53
  }