com.typhoon.unitysdk 1.0.38 → 1.0.40

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.
@@ -60,6 +60,9 @@ namespace TyphoonUnitySDK
60
60
  GUIDrawer.DrawKeynotes("③使用指定广告图标,链接如下:");
61
61
  url = "https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/operation1/advertise/norms";
62
62
  GUIDrawer.DrawUrlLink($" {url}", () => Application.OpenURL(url));
63
+ GUIDrawer.DrawKeynotes("④需要接入侧边栏复访");
64
+ url = "https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/operation1/ability/-retention/sidebar#c6ed8ce0";
65
+ GUIDrawer.DrawUrlLink($" {url}", () => Application.OpenURL(url));
63
66
  GUILayout.Space(6);
64
67
  GUI.enabled = tmpEnable;
65
68
  return true;
@@ -45,9 +45,9 @@ namespace TyphoonUnitySDK
45
45
  public ScriptingImplementation ScriptingImplementation = ScriptingImplementation.IL2CPP;
46
46
 
47
47
 
48
- public bool StripEngineCode = false;
48
+ public bool StripEngineCode = true;
49
49
 
50
- public ManagedStrippingLevel StrippingLevel = ManagedStrippingLevel.Disabled;
50
+ public ManagedStrippingLevel StrippingLevel = ManagedStrippingLevel.Low;
51
51
 
52
52
  #if UNITY_2021
53
53
  public AndroidSdkVersions MinApiVersion = AndroidSdkVersions.AndroidApiLevel22;
@@ -6,10 +6,14 @@ using System.Reflection;
6
6
  using System.Text;
7
7
  using System.Threading.Tasks;
8
8
  using UnityEditor;
9
- using UnityEditor.AssetImporters;
10
9
  using UnityEditor.IMGUI.Controls;
11
10
  using UnityEngine;
12
11
  using Object = UnityEngine.Object;
12
+ #if UNITY_2020_1_OR_NEWER
13
+ using SourceTextureInformation = UnityEditor.AssetImporters.SourceTextureInformation;
14
+ #else
15
+ using SourceTextureInformation = UnityEditor.Experimental.AssetImporters.SourceTextureInformation;
16
+ #endif
13
17
 
14
18
  namespace TyphoonUnitySDK
15
19
  {
@@ -18,6 +22,7 @@ namespace TyphoonUnitySDK
18
22
  /// </summary>
19
23
  public class XCompressTool : EditorWindow
20
24
  {
25
+
21
26
  public struct PathDepth
22
27
  {
23
28
  public string Path;
@@ -360,7 +365,7 @@ namespace TyphoonUnitySDK
360
365
  .GetPlatformTextureSettings(BuildPipeline.GetBuildTargetName(_filterBuildTarget));
361
366
 
362
367
  public string Name => Texture.name;
363
- public UnityEditor.AssetImporters.SourceTextureInformation SourceInfo;
368
+ public SourceTextureInformation SourceInfo;
364
369
  }
365
370
 
366
371
  //属性栏配置
@@ -2648,12 +2653,12 @@ namespace TyphoonUnitySDK
2648
2653
  }
2649
2654
 
2650
2655
 
2651
- public static UnityEditor.AssetImporters.SourceTextureInformation GetSourceTextureInformation(
2656
+ public static SourceTextureInformation GetSourceTextureInformation(
2652
2657
  TextureImporter importer)
2653
2658
  {
2654
2659
  var info =
2655
2660
  Method_GetSourceTextureInformation?.Invoke(importer, null) as
2656
- UnityEditor.AssetImporters.SourceTextureInformation;
2661
+ SourceTextureInformation;
2657
2662
  return info;
2658
2663
  }
2659
2664
 
@@ -267,7 +267,7 @@ namespace TyphoonUnitySDK
267
267
  return AddressableSupport.HasAddressableModule();
268
268
  }
269
269
 
270
- [MenuItem("TyphoonSDK/安装拓展/Toast模块", priority = 100)]
270
+ // [MenuItem("TyphoonSDK/安装拓展/Toast模块", priority = 100)]
271
271
  public static void InstallToast()
272
272
  {
273
273
  AssetDatabase.ImportPackage(UniEditor.PackagePath_Toast, true);
@@ -8,7 +8,7 @@ using UnityEngine;
8
8
 
9
9
  namespace TyphoonUnitySDK
10
10
  {
11
- /*微信小游戏配置GUI绘制*/
11
+ /*VIVO小游戏配置GUI绘制*/
12
12
  public static class VivoMiniConfigGUIDrawer
13
13
  {
14
14
  //微信小游戏进阶设置
@@ -442,8 +442,8 @@ namespace TyphoonUnitySDK
442
442
  public Texture GameIcon; //logo
443
443
  public Texture LoadBackground; //加载背景
444
444
  public Orientation ScreenOrientation = Orientation.Portrait; //屏幕朝向
445
- public bool LimitFps = false;
446
- public int FrameRate = 60;
445
+ public bool LimitFps = true;
446
+ public int FrameRate = 30;
447
447
  public string PrivatePem = "";
448
448
  public string CertificatePem = "";
449
449
  public string VersionName = "0.0.1"; //版本名
@@ -128,13 +128,13 @@ namespace TyphoonUnitySDK
128
128
  #region 录屏分享(抖音小游戏)
129
129
 
130
130
  /*是否支持录屏分享*/
131
- public virtual bool CanRecordGame()
131
+ public virtual bool IsSupportGameRecord()
132
132
  {
133
133
  return false;
134
134
  }
135
135
 
136
136
  /*开始录屏*/
137
- public virtual void StartRecordGame(bool isRecordAudio = true, int maxRecordTimeSec = 600,
137
+ public virtual void StartGameRecord(bool isRecordAudio = true, int maxRecordTimeSec = 600,
138
138
  Action onStart = null,
139
139
  Action<string> onError = null, Action<string> onComplete = null)
140
140
  {
@@ -142,14 +142,14 @@ namespace TyphoonUnitySDK
142
142
  }
143
143
 
144
144
  /*停止录屏*/
145
- public virtual void StopRecordGame(Action<string> complete = null, Action<string> onError = null,
145
+ public virtual void StopGameRecord(Action<string> complete = null, Action<string> onError = null,
146
146
  List<TimeClip> clips = null, bool autoMerge = true)
147
147
  {
148
148
  onError?.Invoke("not support");
149
149
  }
150
150
 
151
151
  /*获取录屏时长*/
152
- public virtual float GetRecordDuration()
152
+ public virtual float GetGameRecordDuration()
153
153
  {
154
154
  return 0;
155
155
  }
@@ -168,6 +168,10 @@ namespace TyphoonUnitySDK
168
168
  fail?.Invoke("not support");
169
169
  }
170
170
 
171
+ public virtual void ClearGameRecord()
172
+ {
173
+ }
174
+
171
175
  #endregion
172
176
 
173
177
  #region Http请求
@@ -187,5 +191,36 @@ namespace TyphoonUnitySDK
187
191
  }
188
192
 
189
193
  #endregion
194
+
195
+ #region 侧边栏复访(抖音小游戏)
196
+
197
+ public virtual void IsSupportSideBar(Action success, Action<string> fail)
198
+ {
199
+ //默认不支持
200
+ fail?.Invoke("no support in this channel");
201
+ }
202
+
203
+ public virtual void NavigateToSideBar(Action success, Action<string> fail)
204
+ {
205
+ //默认不支持
206
+ fail?.Invoke("no support in this channel");
207
+ }
208
+
209
+ public virtual bool IsEnterFromSideBar()
210
+ {
211
+ //默认不支持
212
+ return false;
213
+ }
214
+
215
+ #endregion
216
+
217
+ #region Toast
218
+
219
+ public virtual void ShowToast(string message)
220
+ {
221
+ Toast.Instance.Show(message);
222
+ }
223
+
224
+ #endregion
190
225
  }
191
226
  }
@@ -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, IHttpGet, IHttpPost
10
+ INativeAD, IRecordGame, IHttpGet, IHttpPost, ISideBarReturn, IShowToast
11
11
  {
12
12
  }
13
13
 
@@ -120,27 +120,49 @@ namespace TyphoonUnitySDK
120
120
  public interface IRecordGame
121
121
  {
122
122
  /*是否可以录屏*/
123
- bool CanRecordGame();
123
+ bool IsSupportGameRecord();
124
124
 
125
- /*开启录屏*/
126
- void StartRecordGame(bool isRecordAudio = true, int maxRecordTimeSec = 600,
125
+ /*开启游戏录屏*/
126
+ void StartGameRecord(bool isRecordAudio = true, int maxRecordTimeSec = 600,
127
127
  Action onStart = null, Action<string> onError = null, Action<string> onComplete = null);
128
128
 
129
- /*结束录屏*/
130
- void StopRecordGame(Action<string> complete = null, Action<string> onError = null,
129
+ /*结束游戏录屏*/
130
+ void StopGameRecord(Action<string> complete = null, Action<string> onError = null,
131
131
  List<TimeClip> clips = null,
132
132
  bool autoMerge = true);
133
133
 
134
134
 
135
- /*获取录屏时间*/
136
- float GetRecordDuration();
135
+ /*获取游戏录屏时间*/
136
+ float GetGameRecordDuration();
137
137
 
138
- /*可分享游戏录屏*/
138
+ /*是否可分享游戏录屏*/
139
139
  bool CanShareRecordGame();
140
140
 
141
141
  /*分享游戏录屏*/
142
142
  void ShareRecordGame(string title, List<string> topics, Action success, Action<string> fail = null,
143
143
  Action cancel = null);
144
+
145
+ /*清理游戏录屏*/
146
+ void ClearGameRecord();
147
+ }
148
+
149
+ #endregion
150
+
151
+ #region 侧边栏(抖音小游戏)
152
+
153
+ /// <summary>
154
+ /// 侧边栏回访
155
+ /// </summary>
156
+ public interface ISideBarReturn
157
+ {
158
+ //是都支持侧边栏
159
+ void IsSupportSideBar(Action success, Action<string> fail);
160
+
161
+ //导航到侧边栏
162
+ void NavigateToSideBar(Action success, Action<string> fail);
163
+
164
+ //是否从侧边栏进入
165
+ bool IsEnterFromSideBar();
144
166
  }
145
167
 
146
168
  #endregion
@@ -164,4 +186,17 @@ namespace TyphoonUnitySDK
164
186
  }
165
187
 
166
188
  #endregion
189
+
190
+
191
+ #region ShowToast
192
+
193
+ /// <summary>
194
+ /// 显示toast
195
+ /// </summary>
196
+ public interface IShowToast
197
+ {
198
+ void ShowToast(string message);
199
+ }
200
+
201
+ #endregion
167
202
  }
@@ -0,0 +1,62 @@
1
+ using UnityEngine;
2
+
3
+ namespace TyphoonUnitySDK
4
+ {
5
+ using UnityEngine;
6
+ #if UNITY_EDITOR
7
+ using UnityEditor;
8
+ #endif
9
+
10
+ public class LabelOverride : PropertyAttribute
11
+ {
12
+ public string label;
13
+
14
+ public LabelOverride(string label)
15
+ {
16
+ this.label = label;
17
+ }
18
+
19
+ #if UNITY_EDITOR
20
+ [CustomPropertyDrawer(typeof(LabelOverride))]
21
+ public class ThisPropertyDrawer : PropertyDrawer
22
+ {
23
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
24
+ {
25
+ try
26
+ {
27
+ var propertyAttribute = this.attribute as LabelOverride;
28
+ if (IsItBloodyArrayTho(property) == false)
29
+ {
30
+ label.text = propertyAttribute.label;
31
+ }
32
+ else
33
+ {
34
+ Debug.LogWarningFormat(
35
+ "{0}(\"{1}\") doesn't support arrays ",
36
+ typeof(LabelOverride).Name,
37
+ propertyAttribute.label
38
+ );
39
+ }
40
+
41
+ EditorGUI.PropertyField(position, property, label);
42
+ }
43
+ catch (System.Exception ex)
44
+ {
45
+ Debug.LogException(ex);
46
+ }
47
+ }
48
+
49
+ bool IsItBloodyArrayTho(SerializedProperty property)
50
+ {
51
+ string path = property.propertyPath;
52
+ int idot = path.IndexOf('.');
53
+ if (idot == -1) return false;
54
+ string propName = path.Substring(0, idot);
55
+ SerializedProperty p = property.serializedObject.FindProperty(propName);
56
+ return p.isArray;
57
+ //CREDITS: https://answers.unity.com/questions/603882/serializedproperty-isnt-being-detected-as-an-array.html
58
+ }
59
+ }
60
+ #endif
61
+ }
62
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: ec2c9f1b3c6e01e428e3a0a7057cd678
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -14,6 +14,10 @@ namespace TyphoonUnitySDK
14
14
  public class SDKInteractiveUI : MonoSingleton<SDKInteractiveUI>
15
15
  {
16
16
  #if UNITY_EDITOR
17
+
18
+ public static Color Blue = new Color(0.02f, 0.49f, 0.84f, 0.8f);
19
+ public static Color DarkBlue = new Color(0.05f, 0.33f, 0.61f, 1f);
20
+
17
21
  public static float HOLD_TIME = SdkTestInUnity.Instance.InteractiveHoldCloseTime;
18
22
 
19
23
  public static string PathRoot => RuntimeUtil.GetPathRoot();
@@ -103,7 +107,7 @@ namespace TyphoonUnitySDK
103
107
  Sources =
104
108
  AssetDatabase.LoadAssetAtPath<InteractiveSources>(path);
105
109
  Banner.Initialize(Sources);
106
- Video.Initialize(Sources);
110
+ Video.Initialize();
107
111
  Inters.Initialize(Sources);
108
112
  Native.Initialize(Sources);
109
113
  FloatIcon.Initialize(Sources);
@@ -119,9 +123,9 @@ namespace TyphoonUnitySDK
119
123
  Banner.Hide();
120
124
  }
121
125
 
122
- public void ShowInters()
126
+ public void ShowInters(string scene)
123
127
  {
124
- Inters.Show();
128
+ Inters.Show(scene);
125
129
  }
126
130
 
127
131
  public void ShowVideo(Action success, Action<string> fail)
@@ -244,20 +248,31 @@ namespace TyphoonUnitySDK
244
248
 
245
249
  public class IntersView
246
250
  {
251
+ private const float DURATION = 0.8F;
247
252
  public InteractiveSources Sources;
248
-
249
253
  public bool IsShow = false;
250
- public Texture2D Image => Sources.Get("test_inters");
251
- public float HoldTime = 0;
254
+ public string Scene;
255
+ public float CloseTime;
256
+ public int Length;
257
+ private GUIStyle _labelStyle = null;
252
258
 
253
259
  public void Initialize(InteractiveSources sources)
254
260
  {
255
261
  Sources = sources;
262
+ _labelStyle = new GUIStyle("label");
263
+ _labelStyle.margin = new RectOffset(2, 2, 2, 2);
264
+ _labelStyle.padding = new RectOffset(2, 2, 2, 2);
265
+ _labelStyle.border = new RectOffset(2, 2, 2, 2);
266
+ _labelStyle.alignment = TextAnchor.MiddleCenter;
267
+ // _labelStyle.fontStyle = FontStyle.Bold;
256
268
  }
257
269
 
258
- public void Show()
270
+ public void Show(string scene)
259
271
  {
272
+ Scene = scene;
273
+ Length = scene.Length;
260
274
  IsShow = true;
275
+ CloseTime = Time.realtimeSinceStartup + DURATION;
261
276
  }
262
277
 
263
278
  public void Hide()
@@ -269,28 +284,32 @@ namespace TyphoonUnitySDK
269
284
  {
270
285
  if (IsShow)
271
286
  {
272
- EditorGUI.DrawRect(rect, Color.black);
273
- var size = CalculateImageMatchSize(Image, rect);
274
- var imageRect = rect;
275
- imageRect.width = size.x;
276
- imageRect.height = size.y;
277
- imageRect.center = rect.center;
278
- GUI.DrawTexture(imageRect, Image);
279
-
280
- var rectClose = imageRect;
281
- rectClose.width = 246;
282
- rectClose.height = 66;
283
- rectClose.x = imageRect.xMax - rectClose.width - 10;
284
- rectClose.y += 10;
285
- DrawViewTxtLabel(rectClose, "关闭");
286
- //悬停/关闭
287
- HoldHide(rectClose, ref HoldTime, Hide);
288
-
289
- var titleRect = imageRect;
290
- titleRect.width = 400;
291
- titleRect.height = 128;
292
- titleRect.center = imageRect.center;
293
- DrawViewTxtLabel(titleRect, "这是一个测试插页广告");
287
+ var rectToast = rect;
288
+ rectToast.width = 500;
289
+ rectToast.height = 128;
290
+ rectToast.center = rect.center;
291
+ rectToast.y = rect.yMax - rectToast.height;
292
+ rectToast.y -= 50;
293
+ var startCenter = rectToast.center;
294
+ var endCenter = rectToast.center - Vector2.up * 64;
295
+ var process = 1 - Mathf.Clamp01((CloseTime - Time.realtimeSinceStartup) / DURATION);
296
+ var center = Vector2.Lerp(startCenter, endCenter, process);
297
+ rectToast.center = center;
298
+
299
+ var rectOutline = rectToast;
300
+ rectOutline.width += 8;
301
+ rectOutline.height += 8;
302
+ rectOutline.center = rectToast.center;
303
+
304
+ EditorGUI.DrawRect(rectOutline, DarkBlue);
305
+ EditorGUI.DrawRect(rectToast, Blue);
306
+
307
+ _labelStyle.fontSize = (int)(Mathf.Min(rectToast.width * 0.5f / Length, 48));
308
+ GUI.Label(rectToast, $"弹出插页:{Scene}", _labelStyle);
309
+ if (Time.realtimeSinceStartup > CloseTime)
310
+ {
311
+ Hide();
312
+ }
294
313
  }
295
314
  }
296
315
  }
@@ -301,18 +320,14 @@ namespace TyphoonUnitySDK
301
320
 
302
321
  public class VideoView
303
322
  {
304
- public InteractiveSources Sources;
305
323
  public bool IsShow = false;
306
324
  public Action OnSuccess;
307
325
  public Action OnFail;
308
- public Texture2D Image => Sources.Get("test_inters");
309
- public float HoldTime = 0;
310
326
  public float BtnYesHoldTime = 0;
311
327
  public float BtnNoHoldTime = 0;
312
328
 
313
- public void Initialize(InteractiveSources sources)
329
+ public void Initialize()
314
330
  {
315
- Sources = sources;
316
331
  }
317
332
 
318
333
  public void OnClickSuccess()
@@ -344,41 +359,39 @@ namespace TyphoonUnitySDK
344
359
  {
345
360
  if (IsShow)
346
361
  {
347
- EditorGUI.DrawRect(rect, Color.black);
348
- var size = CalculateImageMatchSize(Image, rect);
349
- var adRect = rect;
350
- adRect.width = size.x;
351
- adRect.height = size.y;
352
- adRect.center = rect.center;
353
- GUI.DrawTexture(adRect, Image);
354
-
355
- var rectClose = adRect;
356
- rectClose.width = 246;
357
- rectClose.height = 66;
358
- rectClose.x = adRect.xMax - rectClose.width - 10;
359
- rectClose.y += 10;
360
- DrawViewTxtLabel(rectClose, "关闭");
361
-
362
- //成功返回
363
- var rectYes = adRect;
362
+ var rectYes = rect;
364
363
  rectYes.width = 346;
365
- rectYes.height = 128;
366
- rectYes.center = new Vector2(adRect.center.x, adRect.center.y + 80);
367
- //失败返回
364
+ rectYes.height = 80;
365
+ rectYes.center = rect.center;
366
+
368
367
  var rectNo = rectYes;
369
- rectNo.center = new Vector2(adRect.center.x, adRect.center.y - 80);
368
+ rectNo.y = rectYes.yMax;
369
+ rectNo.y += 40;
370
+
371
+ var rectTitle = rectYes;
372
+ rectTitle.y = rectYes.yMin - rectTitle.height;
373
+ rectTitle.y -= 40;
374
+ var center = rectTitle.center;
375
+ rectTitle.width = 500;
376
+ rectTitle.center = center;
377
+
378
+ var rectBg = new Rect();
379
+ rectBg.width = rectTitle.width;
380
+ rectBg.height = rectNo.yMax - rectTitle.yMin;
381
+ rectBg.width += 20;
382
+ rectBg.height += 20;
383
+ rectBg.center = rect.center;
384
+
385
+ EditorGUI.DrawRect(rect, Color.black * 0.7f);
386
+ EditorGUI.DrawRect(rectBg, Blue);
387
+
388
+
389
+ //失败返回
370
390
  DrawViewTxtLabel(rectYes, "成功返回");
371
391
  DrawViewTxtLabel(rectNo, "失败返回");
372
392
  HoldHide(rectYes, ref BtnYesHoldTime, OnClickSuccess);
373
393
  HoldHide(rectNo, ref BtnNoHoldTime, OnClickFail);
374
- HoldHide(rectClose, ref HoldTime, OnClickFail);
375
-
376
- var rectTitle = adRect;
377
- rectTitle.width = 400;
378
- rectTitle.height = 128;
379
- rectTitle.center = adRect.center;
380
- rectTitle.y -= 300;
381
- DrawViewTxtLabel(rectTitle, "这是一个测试视频");
394
+ DrawViewTxtLabel(rectTitle, "模拟激励视频");
382
395
  }
383
396
  }
384
397
  }
@@ -1,20 +1,29 @@
1
1
  using System.IO;
2
+ using TyphoonUnitySDK;
2
3
 
3
4
  #if UNITY_EDITOR
4
5
  using UnityEditor;
5
6
  #endif
6
7
  using UnityEngine;
8
+ using UnityEngine.Serialization;
7
9
 
8
10
  public class SdkTestInUnity : ScriptableObject
9
11
  {
10
12
  private const string ASSET_PATH = "Assets/Typhoon_Gen/TyphoonSDK/Editor/SdkTestInUnity.asset";
11
13
 
12
- [Header("登录回调")] public bool LoginResult = true;
13
- [Header("是否支持ExitGame")] public bool IsSupportExitGame = true;
14
- [Header("开启交互式测试")] public bool OpenInteractive = true;
15
- [Header("交互式测试悬停关闭检测时间")] public float InteractiveHoldCloseTime = 1.2f;
16
- [Header("视频广告回调")] public bool ShowVideoResult = true;
17
- [Header("视频广告flag")] public bool GetVideoFlagResult = true;
14
+ [LabelOverride("登录回调")] public bool LoginResult = true;
15
+ [LabelOverride("是否支持ExitGame")] public bool IsSupportExitGame = true;
16
+ [LabelOverride("开启广告交互式测试")] public bool OpenInteractive = true;
17
+ [LabelOverride("广告交互式悬停关闭时间")] public float InteractiveHoldCloseTime = 1.2f;
18
+ [LabelOverride("视频广告flag")] public bool GetVideoFlagResult = true;
19
+ [LabelOverride("视频广告回调")] public bool ShowVideoResult = true;
20
+
21
+ [FormerlySerializedAs("IsSupportSideBar")] [Header("抖音小游戏相关")] [LabelOverride("是否支持侧边栏-回调结果")]
22
+ public bool IsSupportSideBarResult = true;
23
+
24
+ [LabelOverride("导航到侧边栏-回调结果")] public bool NavigateToSideBarResult = true;
25
+
26
+ [LabelOverride("侧边栏进入标记")] public bool IsEnterFromSideBar = true;
18
27
 
19
28
 
20
29
  private static SdkTestInUnity _instance = null;
@@ -67,6 +67,12 @@ namespace TyphoonUnitySDK
67
67
  return RecordTime > 0;
68
68
  }
69
69
 
70
+ public void ClearRecord()
71
+ {
72
+ IsRecording = false;
73
+ RecordTime = 0;
74
+ }
75
+
70
76
  public void Share(Action success, Action fail)
71
77
  {
72
78
  if (!CanShare())
@@ -0,0 +1,108 @@
1
+ using UnityEngine;
2
+
3
+ namespace TyphoonUnitySDK
4
+ {
5
+ internal class Toast : MonoSingleton<Toast>
6
+ {
7
+ private static float RADIAN_90 = 90 * Mathf.Deg2Rad;
8
+
9
+ /*出现动画的时长*/
10
+ private const float APPEAR_DURAITON = 0.25F;
11
+ private const float HIDE_DURAITON = 0.25F;
12
+
13
+ public bool IsPlaying = false;
14
+ public float PlayingTime = 0;
15
+ public float Duration = 2;
16
+ public float HideStartTime;
17
+ public string Message;
18
+ public float Alpha = 0;
19
+ public Texture2D Background;
20
+ private GUIStyle _style;
21
+
22
+ protected override void Init()
23
+ {
24
+ base.Init();
25
+ DontDestroyOnLoad(gameObject);
26
+ Background =
27
+ Resources.Load<Texture2D>("TYPHOON_TEXTURE_TOAST_BLACK");
28
+ _style = new GUIStyle()
29
+ {
30
+ margin = new RectOffset(2, 2, 2, 2),
31
+ border = new RectOffset(2, 2, 2, 2),
32
+ padding = new RectOffset(2, 2, 2, 2),
33
+ alignment = TextAnchor.MiddleCenter,
34
+ fontSize = 14,
35
+ };
36
+ }
37
+
38
+ public void Show(string content, float duration = 1.6f)
39
+ {
40
+ var size = (int)(Screen.width * 0.7f / content.Length);
41
+ _style.fontSize = size;
42
+ Alpha = 0;
43
+ Message = content;
44
+ IsPlaying = true;
45
+ PlayingTime = 0;
46
+ Duration = Mathf.Clamp(duration, 0.5f, float.MaxValue);
47
+ HideStartTime = Duration - HIDE_DURAITON;
48
+ }
49
+
50
+ private void Update()
51
+ {
52
+ if (IsPlaying)
53
+ {
54
+ PlayingTime += Time.unscaledDeltaTime;
55
+ if (PlayingTime < APPEAR_DURAITON)
56
+ {
57
+ var process = PlayingTime / APPEAR_DURAITON;
58
+ var scale = Mathf.Sin(Mathf.Lerp(0, RADIAN_90, process));
59
+ Alpha = scale;
60
+ }
61
+ else if (PlayingTime > HideStartTime)
62
+ {
63
+ var process = (PlayingTime - HideStartTime) / HIDE_DURAITON;
64
+ var alpha = Mathf.Lerp(1, 0, process);
65
+ Alpha = alpha;
66
+ }
67
+ else
68
+ {
69
+ Alpha = 1;
70
+ }
71
+
72
+ if (PlayingTime > Duration)
73
+ {
74
+ IsPlaying = false;
75
+ Alpha = 0;
76
+ }
77
+ }
78
+ }
79
+
80
+ public void Clear()
81
+ {
82
+ IsPlaying = false;
83
+ Alpha = 0;
84
+ }
85
+
86
+
87
+ private void OnGUI()
88
+ {
89
+ if (IsPlaying)
90
+ {
91
+ var temDepth = GUI.depth;
92
+ var temColor = GUI.color;
93
+ GUI.depth = 30000;
94
+ var rect = new Rect(0, 0, Screen.width, Screen.height);
95
+ var rectView = rect;
96
+ rectView.height = rect.height * 0.1f;
97
+ rectView.width = rect.width * 0.8f;
98
+ rectView.center = rect.center;
99
+ _style.normal.textColor = Color.white * Alpha;
100
+ GUI.color = Color.white * Alpha;
101
+ GUI.DrawTexture(rectView, Background);
102
+ GUI.color = temColor;
103
+ GUI.TextArea(rectView, Message, _style);
104
+ GUI.depth = temDepth;
105
+ }
106
+ }
107
+ }
108
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: c419db402591f2142a393b605bc170a7
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -95,7 +95,9 @@ namespace TyphoonUnitySDK
95
95
  #region 初始化SDK
96
96
 
97
97
  /// <summary>
98
- /// 初始化sdk
98
+ /// 初始化sdk(必接)<para></para>
99
+ /// 在成功回调后再执行登录<para></para>
100
+ /// 登录API:<seealso cref="Login"/>
99
101
  /// </summary>
100
102
  public void InitSdk(Action success, Action<string> fail)
101
103
  {
@@ -114,7 +116,9 @@ namespace TyphoonUnitySDK
114
116
  #region 登录
115
117
 
116
118
  /// <summary>
117
- /// 登录
119
+ /// 登录(必接)<para></para>
120
+ /// 请完成初始化并且成功后再调用<para></para>
121
+ /// 初始化API:<seealso cref="InitSdk"/>
118
122
  /// </summary>
119
123
  public void Login(Action success, Action<string> fail)
120
124
  {
@@ -179,7 +183,9 @@ namespace TyphoonUnitySDK
179
183
  #region 视频广告
180
184
 
181
185
  /// <summary>
182
- /// 获取视频广告加载标记
186
+ /// 获取视频广告加载标记<para/>
187
+ /// true:视频广告完成加载<para/>
188
+ /// false:视频广告未完成加载<para/>
183
189
  /// </summary>
184
190
  public bool GetVideoFlag()
185
191
  {
@@ -193,7 +199,7 @@ namespace TyphoonUnitySDK
193
199
  }
194
200
 
195
201
  /// <summary>
196
- /// 视频广告
202
+ /// 展示视频广告
197
203
  /// </summary>
198
204
  /// <param name="scene">广告场景</param>
199
205
  /// <param name="success">成功回调,发放奖励</param>
@@ -229,7 +235,7 @@ namespace TyphoonUnitySDK
229
235
  #region 插页广告
230
236
 
231
237
  /// <summary>
232
- /// 插页广告
238
+ /// 展示插页广告
233
239
  /// </summary>
234
240
  /// <param name="scene">广告场景</param>
235
241
  public void ShowInters(string scene)
@@ -238,7 +244,7 @@ namespace TyphoonUnitySDK
238
244
  #if UNITY_EDITOR
239
245
  if (SdkTestInUnity.Instance.OpenInteractive)
240
246
  {
241
- SDKInteractiveUI.Instance.ShowInters();
247
+ SDKInteractiveUI.Instance.ShowInters(scene);
242
248
  return;
243
249
  }
244
250
 
@@ -373,9 +379,9 @@ namespace TyphoonUnitySDK
373
379
  #region 发布版本号
374
380
 
375
381
  /// <summary>
376
- /// 发布版本号
382
+ /// 获取发布版本号<para/>
383
+ /// 此为内部维护版本号,在发布窗口中进行设置,可显示在loading页中,方便区分包体内容所属什么迭代版本的阶段,避免传错包等问题
377
384
  /// </summary>
378
- /*获取发布版本号信息*/
379
385
  public virtual string GetPublishVersion()
380
386
  {
381
387
  var result = AppConfig.Version;
@@ -472,67 +478,68 @@ namespace TyphoonUnitySDK
472
478
  #region 录屏分享
473
479
 
474
480
  /// <summary>
475
- /// 是否支持录屏分享
481
+ /// 是否支持录屏分享(抖音小游戏)
476
482
  /// </summary>
477
- public bool CanRecordGame()
483
+ public bool IsSupportGameRecord()
478
484
  {
479
485
  #if UNITY_EDITOR
480
486
  return SimulateRecordGame.Instance.CanRecord();
481
487
  #endif
482
- return _sdk.CanRecordGame();
488
+ return _sdk.IsSupportGameRecord();
483
489
  }
484
490
 
485
491
  /// <summary>
486
- /// 开启录屏
492
+ /// 开启游戏录屏(抖音小游戏)
487
493
  /// </summary>
488
494
  /// <param name="isRecordAudio">包含音频</param>
489
495
  /// <param name="maxRecordTimeSec">最大录屏时长</param>
490
496
  /// <param name="onStart">开始回调</param>
491
497
  /// <param name="onError">错误回调</param>
492
498
  /// <param name="onComplete">完成回调</param>
493
- public void StartRecordGame(bool isRecordAudio = true, int maxRecordTimeSec = 600, Action onStart = null,
499
+ public void StartGameRecord(bool isRecordAudio = true, int maxRecordTimeSec = 600, Action onStart = null,
494
500
  Action<string> onError = null, Action<string> onComplete = null)
495
501
  {
496
502
  #if UNITY_EDITOR
497
503
  SimulateRecordGame.Instance.StartRecord(onStart);
498
504
  return;
499
505
  #endif
500
- _sdk.StartRecordGame(isRecordAudio, maxRecordTimeSec, onStart, onError, onComplete);
506
+ _sdk.StartGameRecord(isRecordAudio, maxRecordTimeSec, onStart, onError, onComplete);
501
507
  }
502
508
 
503
509
  /// <summary>
504
- /// 停止录制
510
+ /// 结束游戏录制(抖音小游戏)
505
511
  /// </summary>
506
512
  /// <param name="complete">完成回调,返回videopath</param>
507
513
  /// <param name="onError">错误回调</param>
508
514
  /// <param name="clips">自定义剪辑片段,单位毫秒</param>
509
515
  /// <param name="autoMerge">自动合并</param>
510
- public void StopRecordGame(Action<string> complete = null, Action<string> onError = null,
516
+ public void StopGameRecord(Action<string> complete = null, Action<string> onError = null,
511
517
  List<TimeClip> clips = null, bool autoMerge = true)
512
518
  {
513
519
  #if UNITY_EDITOR
514
520
  SimulateRecordGame.Instance.StopRecord(complete);
515
521
  return;
516
522
  #endif
517
- _sdk.StopRecordGame(complete, onError, clips, autoMerge);
523
+ _sdk.StopGameRecord(complete, onError, clips, autoMerge);
518
524
  }
519
525
 
520
526
  /// <summary>
521
- /// 获取录屏时长
527
+ /// 获取录屏时长(抖音小游戏)
522
528
  /// </summary>
523
- public float GetRecordDuration()
529
+ public float GetGameRecordDuration()
524
530
  {
525
531
  #if UNITY_EDITOR
526
532
  return SimulateRecordGame.Instance.GetDuration();
527
533
  #endif
528
- return _sdk.GetRecordDuration();
534
+ return _sdk.GetGameRecordDuration();
529
535
  }
530
536
 
531
537
 
532
538
  /// <summary>
533
- /// 是否可以分享录屏
539
+ /// 是否可以分享录屏(抖音小游戏)<para/>
540
+ /// 当为true可以激活分享按钮
534
541
  /// </summary>
535
- public bool CanShareRecordGame()
542
+ public bool CanShareGameRecord()
536
543
  {
537
544
  #if UNITY_EDITOR
538
545
  return SimulateRecordGame.Instance.CanShare();
@@ -545,10 +552,10 @@ namespace TyphoonUnitySDK
545
552
  /// </summary>
546
553
  /// <param name="title">标题</param>
547
554
  /// <param name="topics">话题</param>
548
- /// <param name="success">成功回调</param>
555
+ /// <param name="success">成功回调,可以下发奖励</param>
549
556
  /// <param name="fail">失败回调</param>
550
557
  /// <param name="cancel">取消回调</param>
551
- public void ShareRecordGame(string title, List<string> topics, Action success, Action<string> fail = null,
558
+ public void ShareGameRecord(string title, List<string> topics, Action success, Action<string> fail = null,
552
559
  Action cancel = null)
553
560
  {
554
561
  #if UNITY_EDITOR
@@ -558,10 +565,32 @@ namespace TyphoonUnitySDK
558
565
  _sdk.ShareRecordGame(title, topics, success, fail, cancel);
559
566
  }
560
567
 
568
+
569
+ /// <summary>
570
+ /// 清理游戏录屏(抖音小游戏)
571
+ /// </summary>
572
+ public void ClearGameRecord()
573
+ {
574
+ #if UNITY_EDITOR
575
+ SimulateRecordGame.Instance.ClearRecord();
576
+ return;
577
+ #endif
578
+ _sdk.ClearGameRecord();
579
+ }
580
+
561
581
  #endregion
562
582
 
563
583
  #region Http请求
564
584
 
585
+ /// <summary>
586
+ /// http post 请求
587
+ /// </summary>
588
+ /// <param name="url">地址</param>
589
+ /// <param name="data">传输的数据</param>
590
+ /// <param name="success">成功回调</param>
591
+ /// <param name="fail">失败回调</param>
592
+ /// <param name="header">请求头</param>
593
+ /// <param name="timeOut">超时时间</param>
565
594
  public virtual void HttpPost(string url, string data, Action<HttpPostSuccessResult> success,
566
595
  Action<string> fail,
567
596
  Dictionary<string, string> header = null, int timeOut = 60)
@@ -573,7 +602,14 @@ namespace TyphoonUnitySDK
573
602
  _sdk?.HttpPost(url, data, success, fail, header, timeOut);
574
603
  }
575
604
 
576
-
605
+ /// <summary>
606
+ /// http get 请求
607
+ /// </summary>
608
+ /// <param name="url">地址</param>
609
+ /// <param name="success">成功回调</param>
610
+ /// <param name="fail">失败回调</param>
611
+ /// <param name="header">请求头</param>
612
+ /// <param name="timeOut">超时时间</param>
577
613
  public virtual void HttpGet(string url, Action<HttpGetSuccessResult> success, Action<string> fail,
578
614
  Dictionary<string, string> header = null, int timeOut = 60)
579
615
  {
@@ -585,5 +621,124 @@ namespace TyphoonUnitySDK
585
621
  }
586
622
 
587
623
  #endregion
624
+
625
+ #region 侧边栏(抖音小游戏)
626
+
627
+ /// <summary>
628
+ /// 判断是否支持侧边栏,可以通过此接口判断是否开启侧边栏奖励入口
629
+ /// </summary>
630
+ /// <param name="success">成功回调,表示支持该功能,可以显示入口</param>
631
+ /// <param name="fail">失败回调,表示不支持该功能,可以显示入口</param>
632
+ public virtual void IsSupportSideBar(Action success, Action<string> fail)
633
+ {
634
+ #if UNITY_EDITOR
635
+ switch (AppConfig.Channel)
636
+ {
637
+ case AppChannel.DouyinAndroid:
638
+ case AppChannel.DouyinIOS:
639
+ break;
640
+ default:
641
+ fail?.Invoke($"[{AppConfig.Channel}]渠道不支持侧边栏功能");
642
+ return;
643
+ }
644
+
645
+ if (SdkTestInUnity.Instance.IsSupportSideBarResult)
646
+ {
647
+ success?.Invoke();
648
+ }
649
+ else
650
+ {
651
+ fail?.Invoke("not support");
652
+ Debug.Log("<color=#e53e30> [SDK模拟] 是否支持侧边栏-回调结果==false,可从'TyphoonSDK/模拟测试'修改</color>");
653
+ }
654
+
655
+ return;
656
+ #endif
657
+ _sdk.IsSupportSideBar(success, fail);
658
+ }
659
+
660
+ /// <summary>
661
+ /// 帮用户跳转到侧边栏
662
+ /// </summary>
663
+ /// <param name="success">跳转成功回调</param>
664
+ /// <param name="fail">跳转失败回调,内部会做提示</param>
665
+ public virtual void NavigateToSideBar(Action success, Action<string> fail, bool showFailToast = true)
666
+ {
667
+ #if UNITY_EDITOR
668
+ switch (AppConfig.Channel)
669
+ {
670
+ case AppChannel.DouyinAndroid:
671
+ case AppChannel.DouyinIOS:
672
+ break;
673
+ default:
674
+ fail?.Invoke($"[{AppConfig.Channel}]渠道不支持侧边栏功能");
675
+ return;
676
+ }
677
+
678
+ if (SdkTestInUnity.Instance.NavigateToSideBarResult)
679
+ {
680
+ success?.Invoke();
681
+ }
682
+ else
683
+ {
684
+ if (showFailToast)
685
+ {
686
+ ShowToast("跳转失败,可主动从侧边栏访问本游戏后领奖");
687
+ }
688
+
689
+ fail?.Invoke("not support");
690
+ Debug.Log("<color=#e53e30> [SDK模拟] 导航到侧边栏-回调结果==false,可从'TyphoonSDK/模拟测试'修改</color>");
691
+ }
692
+
693
+ return;
694
+ #endif
695
+ _sdk.NavigateToSideBar(success, fail);
696
+ }
697
+
698
+ /// <summary>
699
+ /// 是否从侧边栏进入
700
+ /// 当为true,满足侧边栏奖励下发条件,激活领取奖励按钮
701
+ /// </summary>
702
+ public virtual bool IsEnterFromSideBar()
703
+ {
704
+ #if UNITY_EDITOR
705
+ switch (AppConfig.Channel)
706
+ {
707
+ case AppChannel.DouyinAndroid:
708
+ case AppChannel.DouyinIOS:
709
+ {
710
+ if (!SdkTestInUnity.Instance.IsEnterFromSideBar)
711
+ {
712
+ Debug.Log("<color=#e53e30> [SDK模拟] 侧边栏进入标记==false,可从'TyphoonSDK/模拟测试'修改</color>");
713
+ }
714
+
715
+ return SdkTestInUnity.Instance.IsEnterFromSideBar;
716
+ }
717
+ }
718
+
719
+ return false;
720
+ #endif
721
+ return _sdk.IsEnterFromSideBar();
722
+ }
723
+
724
+ #endregion
725
+
726
+ #region Toast
727
+
728
+ /// <summary>
729
+ /// 显示Toast,类似于android的toast
730
+ /// 根据渠道不同显示的形式不同,请规避显示长文本,主要用于简短提示
731
+ /// </summary>
732
+ /// <param name="message">信息</param>
733
+ public virtual void ShowToast(string message)
734
+ {
735
+ #if UNITY_EDITOR
736
+ Toast.Instance.Show(message);
737
+ return;
738
+ #endif
739
+ _sdk.ShowToast(message);
740
+ }
741
+
742
+ #endregion
588
743
  }
589
744
  }
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"com.typhoon.unitysdk","displayName":"typhoon unity sdk","version":"1.0.38","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"}],"dependencies":{"com.unity.nuget.newtonsoft-json":"2.0.0"}}
1
+ {"name":"com.typhoon.unitysdk","displayName":"typhoon unity sdk","version":"1.0.40","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"}],"dependencies":{"com.unity.nuget.newtonsoft-json":"2.0.0"}}