com.typhoon.unitysdk 1.0.38 → 1.0.39
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/Editor/DouyinConfig.cs +3 -0
- package/Editor/PublishSetting.cs +2 -2
- package/Editor/ToolBox/CompressTextureTool/XCompressTool.cs +9 -4
- package/Editor/UniEditor.cs +1 -1
- package/Editor/VivoMiniConfig.cs +3 -3
- package/Runtime/BaseSdk.cs +39 -4
- package/Runtime/Interface.cs +44 -9
- package/Runtime/LabelOverride.cs +62 -0
- package/Runtime/LabelOverride.cs.meta +11 -0
- package/Runtime/SdkTestInUnity.cs +15 -6
- package/Runtime/SimulateRecordGame.cs +6 -0
- package/Runtime/Toast.cs +108 -0
- package/Runtime/Toast.cs.meta +11 -0
- package/Runtime/TyphoonSdk.cs +179 -24
- package/Sources~/Package/Douyin.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/Editor/DouyinConfig.cs
CHANGED
|
@@ -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;
|
package/Editor/PublishSetting.cs
CHANGED
|
@@ -45,9 +45,9 @@ namespace TyphoonUnitySDK
|
|
|
45
45
|
public ScriptingImplementation ScriptingImplementation = ScriptingImplementation.IL2CPP;
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
public bool StripEngineCode =
|
|
48
|
+
public bool StripEngineCode = true;
|
|
49
49
|
|
|
50
|
-
public ManagedStrippingLevel StrippingLevel = ManagedStrippingLevel.
|
|
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
|
|
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
|
|
2656
|
+
public static SourceTextureInformation GetSourceTextureInformation(
|
|
2652
2657
|
TextureImporter importer)
|
|
2653
2658
|
{
|
|
2654
2659
|
var info =
|
|
2655
2660
|
Method_GetSourceTextureInformation?.Invoke(importer, null) as
|
|
2656
|
-
|
|
2661
|
+
SourceTextureInformation;
|
|
2657
2662
|
return info;
|
|
2658
2663
|
}
|
|
2659
2664
|
|
package/Editor/UniEditor.cs
CHANGED
|
@@ -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);
|
package/Editor/VivoMiniConfig.cs
CHANGED
|
@@ -8,7 +8,7 @@ using UnityEngine;
|
|
|
8
8
|
|
|
9
9
|
namespace TyphoonUnitySDK
|
|
10
10
|
{
|
|
11
|
-
|
|
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 =
|
|
446
|
-
public int FrameRate =
|
|
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"; //版本名
|
package/Runtime/BaseSdk.cs
CHANGED
|
@@ -128,13 +128,13 @@ namespace TyphoonUnitySDK
|
|
|
128
128
|
#region 录屏分享(抖音小游戏)
|
|
129
129
|
|
|
130
130
|
/*是否支持录屏分享*/
|
|
131
|
-
public virtual bool
|
|
131
|
+
public virtual bool IsSupportGameRecord()
|
|
132
132
|
{
|
|
133
133
|
return false;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
/*开始录屏*/
|
|
137
|
-
public virtual void
|
|
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
|
|
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
|
|
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
|
}
|
package/Runtime/Interface.cs
CHANGED
|
@@ -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
|
|
123
|
+
bool IsSupportGameRecord();
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
void
|
|
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
|
|
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
|
|
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
|
+
}
|
|
@@ -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
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
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;
|
package/Runtime/Toast.cs
ADDED
|
@@ -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
|
+
}
|
package/Runtime/TyphoonSdk.cs
CHANGED
|
@@ -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)
|
|
@@ -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
|
|
483
|
+
public bool IsSupportGameRecord()
|
|
478
484
|
{
|
|
479
485
|
#if UNITY_EDITOR
|
|
480
486
|
return SimulateRecordGame.Instance.CanRecord();
|
|
481
487
|
#endif
|
|
482
|
-
return _sdk.
|
|
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
|
|
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.
|
|
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
|
|
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.
|
|
523
|
+
_sdk.StopGameRecord(complete, onError, clips, autoMerge);
|
|
518
524
|
}
|
|
519
525
|
|
|
520
526
|
/// <summary>
|
|
521
|
-
///
|
|
527
|
+
/// 获取录屏时长(抖音小游戏)
|
|
522
528
|
/// </summary>
|
|
523
|
-
public float
|
|
529
|
+
public float GetGameRecordDuration()
|
|
524
530
|
{
|
|
525
531
|
#if UNITY_EDITOR
|
|
526
532
|
return SimulateRecordGame.Instance.GetDuration();
|
|
527
533
|
#endif
|
|
528
|
-
return _sdk.
|
|
534
|
+
return _sdk.GetGameRecordDuration();
|
|
529
535
|
}
|
|
530
536
|
|
|
531
537
|
|
|
532
538
|
/// <summary>
|
|
533
|
-
///
|
|
539
|
+
/// 是否可以分享录屏(抖音小游戏)<para/>
|
|
540
|
+
/// 当为true可以激活分享按钮
|
|
534
541
|
/// </summary>
|
|
535
|
-
public bool
|
|
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"
|
|
555
|
+
/// <param name="success">成功回调,可以下发奖励</param>
|
|
549
556
|
/// <param name="fail">失败回调</param>
|
|
550
557
|
/// <param name="cancel">取消回调</param>
|
|
551
|
-
public void
|
|
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
|
}
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"com.typhoon.unitysdk","displayName":"typhoon unity sdk","version":"1.0.
|
|
1
|
+
{"name":"com.typhoon.unitysdk","displayName":"typhoon unity sdk","version":"1.0.39","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"}}
|