com.typhoon.unitysdk 1.0.37 → 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 +2849 -0
- package/Editor/ToolBox/CompressTextureTool/XCompressTool.cs.meta +11 -0
- package/Editor/ToolBox/CompressTextureTool.meta +8 -0
- package/Editor/ToolBox.meta +8 -0
- 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/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
|
+
}
|