com.typhoon.unitysdk 1.0.9 → 1.0.11
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/EditorIcons.cs +27 -45
- package/Editor/Interactive/test_banner.png +0 -0
- package/Editor/Interactive/{sdk_banner.png.meta → test_banner.png.meta} +6 -6
- package/Editor/Interactive/test_banner_2.png +0 -0
- package/Editor/Interactive/{sdk_close.png.meta → test_banner_2.png.meta} +25 -1
- package/Editor/Interactive/test_float_icon_1.png +0 -0
- package/Editor/Interactive/{sdk_/345/244/261/350/264/245/350/277/224/345/233/236.png.meta → test_float_icon_1.png.meta} +25 -1
- package/Editor/Interactive/test_float_icon_2.png +0 -0
- package/Editor/Interactive/{sdk_white_4x4.png.meta → test_float_icon_2.png.meta} +25 -1
- package/Editor/Interactive/test_float_icon_3.png +0 -0
- package/Editor/Interactive/test_float_icon_3.png.meta +144 -0
- package/Editor/Interactive/test_float_icon_4.png +0 -0
- package/Editor/Interactive/test_float_icon_4.png.meta +144 -0
- package/Editor/Interactive/test_inters.png +0 -0
- package/Editor/Interactive/test_inters.png.meta +144 -0
- package/Editor/Interactive/test_native.png +0 -0
- package/Editor/Interactive/test_native.png.meta +144 -0
- package/Editor/InteractiveSources.asset +23 -0
- package/Editor/{Interactive/SDKInteractiveUI.prefab.meta → InteractiveSources.asset.meta} +3 -2
- package/Editor/PreferencesWindow.cs +8 -9
- package/Editor/PublishSettingGUIDrawer.cs +4 -1
- package/Editor/PublishVivoBatSettingWindow.cs +3 -4
- package/Editor/PublishWindow.cs +39 -29
- package/Editor/Skin.guiskin +119 -864
- package/Editor/SkinLight.guiskin +1994 -0
- package/Editor/SkinLight.guiskin.meta +8 -0
- package/Editor/Skins.cs +20 -1
- package/Editor/SkinsTexture.asset +133 -0
- package/Editor/SkinsTexture.asset.meta +8 -0
- package/Editor/Styles.cs +3 -14
- package/Editor/StylesExtension.cs +7 -5
- package/Editor/Texture/{btn_active.png.meta → dark_active.png.meta} +120 -120
- package/Editor/Texture/{btn_hover.png.meta → dark_hover.png.meta} +120 -120
- package/Editor/Texture/{btn_normal.png.meta → dark_normal.png.meta} +120 -120
- package/Editor/Texture/icon_android.png.meta +120 -120
- package/Editor/Texture/icon_douyin.png.meta +120 -120
- package/Editor/Texture/icon_download.png +0 -0
- package/Editor/Texture/icon_download.png.meta +120 -120
- package/Editor/Texture/icon_extension.png +0 -0
- package/Editor/Texture/icon_extension.png.meta +120 -120
- package/Editor/Texture/icon_googleplay.png.meta +120 -120
- package/Editor/Texture/icon_html5.png.meta +120 -120
- package/Editor/Texture/icon_import.png +0 -0
- package/Editor/Texture/icon_ios.png.meta +120 -120
- package/Editor/Texture/icon_oppo.png.meta +120 -120
- package/Editor/Texture/icon_refresh.png +0 -0
- package/Editor/Texture/icon_refresh.png.meta +120 -120
- package/Editor/Texture/icon_save.png +0 -0
- package/Editor/Texture/icon_save.png.meta +120 -120
- package/Editor/Texture/icon_search.png +0 -0
- package/Editor/Texture/{btn_blue_active.png.meta → icon_search.png.meta} +25 -1
- package/Editor/Texture/icon_vivo.png.meta +120 -120
- package/Editor/Texture/icon_wechat.png.meta +120 -120
- package/Editor/Texture/light_active.png +0 -0
- package/Editor/Texture/{btn_blue_hover.png.meta → light_active.png.meta} +25 -1
- package/Editor/Texture/light_hover.png +0 -0
- package/Editor/Texture/light_hover.png.meta +144 -0
- package/Editor/Texture/light_normal.png +0 -0
- package/Editor/Texture/light_normal.png.meta +144 -0
- package/Editor/Texture/tex_select.png.meta +120 -120
- package/Runtime/InteractiveSources.cs +34 -0
- package/{Editor/OriginalStyles.cs.meta → Runtime/InteractiveSources.cs.meta} +1 -1
- package/Runtime/SDKInteractiveUI.cs +432 -117
- package/Runtime/SdkTestInUnity.cs +2 -0
- package/Runtime/TyphoonSdk.cs +75 -97
- package/Sources~/ChinaAndroid/Assets/Typhoon_Gen/TyphoonSDK/Runtime/ChinaAndroid/Editor/PublishChinaAndroidAAR.cs +2 -2
- package/package.json +1 -1
- package/Editor/Interactive/SDKInteractiveUI.prefab +0 -3026
- package/Editor/Interactive/sdk_banner.png +0 -0
- package/Editor/Interactive/sdk_close.png +0 -0
- package/Editor/Interactive/sdk_inters.png +0 -0
- package/Editor/Interactive/sdk_inters.png.meta +0 -120
- package/Editor/Interactive/sdk_white_4x4.png +0 -0
- package/Editor/Interactive/sdk_/345/244/261/350/264/245/350/277/224/345/233/236.png +0 -0
- package/Editor/Interactive/sdk_/346/202/254/346/265/256/345/271/277/345/221/212.png +0 -0
- package/Editor/Interactive/sdk_/346/202/254/346/265/256/345/271/277/345/221/212.png.meta +0 -120
- package/Editor/Interactive/sdk_/346/210/220/345/212/237/350/277/224/345/233/236.png +0 -0
- package/Editor/Interactive/sdk_/346/210/220/345/212/237/350/277/224/345/233/236.png.meta +0 -120
- package/Editor/Interactive/sdk_/350/277/231/346/230/257/344/270/200/344/270/252/345/216/237/347/224/237/346/250/241/346/235/277.png +0 -0
- package/Editor/Interactive/sdk_/350/277/231/346/230/257/344/270/200/344/270/252/345/216/237/347/224/237/346/250/241/346/235/277.png.meta +0 -120
- package/Editor/Interactive/sdk_/350/277/231/346/230/257/344/270/200/344/270/252/346/217/222/351/241/265/345/271/277/345/221/212.png +0 -0
- package/Editor/Interactive/sdk_/350/277/231/346/230/257/344/270/200/344/270/252/346/217/222/351/241/265/345/271/277/345/221/212.png.meta +0 -120
- package/Editor/Interactive/sdk_/350/277/231/346/230/257/344/270/200/344/270/252/350/247/206/351/242/221/345/271/277/345/221/212.png +0 -0
- package/Editor/Interactive/sdk_/350/277/231/346/230/257/344/270/200/344/270/252/350/247/206/351/242/221/345/271/277/345/221/212.png.meta +0 -120
- package/Editor/OriginalStyles.cs +0 -708
- package/Editor/StyleEditorWindow.cs +0 -23
- package/Editor/StyleEditorWindow.cs.meta +0 -11
- package/Editor/Texture/btn_blue_active.png +0 -0
- package/Editor/Texture/btn_blue_hover.png +0 -0
- package/Editor/Texture/btn_blue_normal.png +0 -0
- package/Editor/Texture/btn_blue_normal.png.meta +0 -120
- package/Editor/Texture/btn_green_active.png +0 -0
- package/Editor/Texture/btn_green_active.png.meta +0 -120
- package/Editor/Texture/btn_green_hover.png +0 -0
- package/Editor/Texture/btn_green_hover.png.meta +0 -120
- package/Editor/Texture/btn_green_normal.png +0 -0
- package/Editor/Texture/btn_green_normal.png.meta +0 -120
- package/Editor/Texture/btn_yellow_active.png +0 -0
- package/Editor/Texture/btn_yellow_active.png.meta +0 -120
- package/Editor/Texture/btn_yellow_hover.png +0 -0
- package/Editor/Texture/btn_yellow_hover.png.meta +0 -120
- package/Editor/Texture/btn_yellow_normal.png +0 -0
- package/Editor/Texture/btn_yellow_normal.png.meta +0 -120
- /package/Editor/Texture/{btn_active.png → dark_active.png} +0 -0
- /package/Editor/Texture/{btn_hover.png → dark_hover.png} +0 -0
- /package/Editor/Texture/{btn_normal.png → dark_normal.png} +0 -0
|
@@ -2,7 +2,6 @@ using System;
|
|
|
2
2
|
using System.Collections.Generic;
|
|
3
3
|
using System.IO;
|
|
4
4
|
using UnityEngine;
|
|
5
|
-
using UnityEngine.UI;
|
|
6
5
|
#if UNITY_EDITOR
|
|
7
6
|
using UnityEditor;
|
|
8
7
|
#endif
|
|
@@ -14,6 +13,9 @@ namespace TyphoonUnitySDK
|
|
|
14
13
|
/// </summary>
|
|
15
14
|
public class SDKInteractiveUI : MonoSingleton<SDKInteractiveUI>
|
|
16
15
|
{
|
|
16
|
+
#if UNITY_EDITOR
|
|
17
|
+
public static float HOLD_TIME = SdkTestInUnity.Instance.InteractiveHoldCloseTime;
|
|
18
|
+
|
|
17
19
|
public static string PathRoot
|
|
18
20
|
{
|
|
19
21
|
get
|
|
@@ -36,51 +38,86 @@ namespace TyphoonUnitySDK
|
|
|
36
38
|
Portrait,
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
public ScreenMode Mode;
|
|
40
|
-
|
|
41
41
|
public BannerView Banner = new BannerView();
|
|
42
42
|
public IntersView Inters = new IntersView();
|
|
43
43
|
public VideoView Video = new VideoView();
|
|
44
44
|
public NativeView Native = new NativeView();
|
|
45
45
|
public FloatIconView FloatIcon = new FloatIconView();
|
|
46
|
+
public InteractiveSources Sources;
|
|
47
|
+
public GUISkin Skin;
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
protected override void Init()
|
|
49
|
+
public class UIStyles
|
|
49
50
|
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
Debug.Log($" {Screen.width},{Screen.height}");
|
|
51
|
+
private static GUIStyle _bottomImageStyle = null;
|
|
52
|
+
private static GUIStyle _topmageStyle = null;
|
|
53
|
+
private static GUIStyle _boldLabel = null;
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
public static GUIStyle BoldLabel
|
|
56
|
+
{
|
|
57
|
+
get
|
|
58
|
+
{
|
|
59
|
+
if (_boldLabel == null)
|
|
60
|
+
{
|
|
61
|
+
_boldLabel = new GUIStyle(GUI.skin.label);
|
|
62
|
+
_boldLabel.alignment = TextAnchor.MiddleCenter;
|
|
63
|
+
_boldLabel.fixedWidth = 0;
|
|
64
|
+
_boldLabel.fixedHeight = 0;
|
|
65
|
+
_boldLabel.fontSize = 30;
|
|
66
|
+
_boldLabel.fontStyle = FontStyle.Bold;
|
|
67
|
+
_boldLabel.normal.textColor = Color.white;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return _boldLabel;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
public static GUIStyle BottomImageStyle
|
|
75
|
+
{
|
|
76
|
+
get
|
|
77
|
+
{
|
|
78
|
+
if (_bottomImageStyle == null)
|
|
79
|
+
{
|
|
80
|
+
_bottomImageStyle = new GUIStyle(GUI.skin.box);
|
|
81
|
+
_bottomImageStyle.alignment = TextAnchor.LowerCenter;
|
|
82
|
+
_bottomImageStyle.fixedWidth = 0;
|
|
83
|
+
_bottomImageStyle.fixedHeight = 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return _bottomImageStyle;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public static GUIStyle TopImageStyle
|
|
91
|
+
{
|
|
92
|
+
get
|
|
93
|
+
{
|
|
94
|
+
if (_topmageStyle == null)
|
|
95
|
+
{
|
|
96
|
+
_topmageStyle = new GUIStyle(GUI.skin.box);
|
|
97
|
+
_topmageStyle.alignment = TextAnchor.UpperCenter;
|
|
98
|
+
_topmageStyle.fixedWidth = 0;
|
|
99
|
+
_topmageStyle.fixedHeight = 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return _topmageStyle;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
78
105
|
}
|
|
79
106
|
|
|
80
|
-
|
|
107
|
+
protected override void Init()
|
|
81
108
|
{
|
|
82
|
-
|
|
83
|
-
|
|
109
|
+
base.Init();
|
|
110
|
+
DontDestroyOnLoad(gameObject);
|
|
111
|
+
Skin =
|
|
112
|
+
AssetDatabase.LoadAssetAtPath<GUISkin>($"{PathRoot}/Editor/Skin.guiskin");
|
|
113
|
+
var path = $"{PathRoot}/Editor/InteractiveSources.asset";
|
|
114
|
+
Sources =
|
|
115
|
+
AssetDatabase.LoadAssetAtPath<InteractiveSources>(path);
|
|
116
|
+
Banner.Initialize(Sources);
|
|
117
|
+
Video.Initialize(Sources);
|
|
118
|
+
Inters.Initialize(Sources);
|
|
119
|
+
Native.Initialize(Sources);
|
|
120
|
+
FloatIcon.Initialize(Sources);
|
|
84
121
|
}
|
|
85
122
|
|
|
86
123
|
public void ShowBanner(BannerPosition position)
|
|
@@ -129,34 +166,86 @@ namespace TyphoonUnitySDK
|
|
|
129
166
|
|
|
130
167
|
public class BannerView
|
|
131
168
|
{
|
|
132
|
-
public
|
|
133
|
-
public
|
|
134
|
-
public
|
|
135
|
-
public
|
|
136
|
-
public
|
|
137
|
-
|
|
138
|
-
public
|
|
139
|
-
{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
169
|
+
public bool IsShow = false;
|
|
170
|
+
public BannerPosition BannerPosition;
|
|
171
|
+
public InteractiveSources Sources;
|
|
172
|
+
public GUIStyle TopStyle => UIStyles.TopImageStyle;
|
|
173
|
+
public GUIStyle BottomStyle => UIStyles.BottomImageStyle;
|
|
174
|
+
|
|
175
|
+
public Texture2D Image
|
|
176
|
+
{
|
|
177
|
+
get
|
|
178
|
+
{
|
|
179
|
+
switch (BannerPosition)
|
|
180
|
+
{
|
|
181
|
+
case BannerPosition.Top:
|
|
182
|
+
return Sources.Get("test_banner_2");
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return Sources.Get("test_banner");
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
public float HoldTime = 0;
|
|
190
|
+
|
|
191
|
+
public void Initialize(InteractiveSources sources)
|
|
192
|
+
{
|
|
193
|
+
Sources = sources;
|
|
148
194
|
}
|
|
149
195
|
|
|
150
196
|
public void Show(BannerPosition position)
|
|
151
197
|
{
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
198
|
+
IsShow = true;
|
|
199
|
+
BannerPosition = position;
|
|
200
|
+
HoldTime = 0;
|
|
155
201
|
}
|
|
156
202
|
|
|
157
203
|
public void Hide()
|
|
158
204
|
{
|
|
159
|
-
|
|
205
|
+
IsShow = false;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
public void OnGUI(Rect rect, ScreenMode mode)
|
|
210
|
+
{
|
|
211
|
+
if (IsShow)
|
|
212
|
+
{
|
|
213
|
+
var heightScale = mode == ScreenMode.Portrait ? 0.1f : 0.07f;
|
|
214
|
+
var height = heightScale * rect.height;
|
|
215
|
+
var view = rect;
|
|
216
|
+
view.height = height;
|
|
217
|
+
var size = CalculateImageMatchSize(Image, view);
|
|
218
|
+
view.width = size.x;
|
|
219
|
+
view.height = size.y;
|
|
220
|
+
view.y = 0;
|
|
221
|
+
if (BannerPosition == BannerPosition.Bottom)
|
|
222
|
+
{
|
|
223
|
+
view.y = rect.yMax - view.height;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
view.x = rect.center.x - view.width * 0.5f;
|
|
227
|
+
GUI.DrawTexture(view, Image, ScaleMode.StretchToFill);
|
|
228
|
+
//绘制关闭按钮
|
|
229
|
+
var rectClose = view;
|
|
230
|
+
rectClose.width = 146;
|
|
231
|
+
rectClose.height = 60;
|
|
232
|
+
rectClose.x = view.xMax - rectClose.width - 6;
|
|
233
|
+
rectClose.y = 6;
|
|
234
|
+
if (BannerPosition == BannerPosition.Bottom)
|
|
235
|
+
{
|
|
236
|
+
rectClose.y = view.y + 10;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
DrawViewTxtLabel(rectClose, "关闭");
|
|
240
|
+
//悬停/关闭
|
|
241
|
+
HoldHide(rectClose, ref HoldTime, Hide);
|
|
242
|
+
|
|
243
|
+
var rectTitle = view;
|
|
244
|
+
rectTitle.width = 300;
|
|
245
|
+
rectTitle.height = 66;
|
|
246
|
+
rectTitle.center = view.center;
|
|
247
|
+
DrawViewTxtLabel(rectTitle, "这是一个测试Banner");
|
|
248
|
+
}
|
|
160
249
|
}
|
|
161
250
|
}
|
|
162
251
|
|
|
@@ -166,25 +255,54 @@ namespace TyphoonUnitySDK
|
|
|
166
255
|
|
|
167
256
|
public class IntersView
|
|
168
257
|
{
|
|
169
|
-
public
|
|
170
|
-
public Button BtnClose;
|
|
258
|
+
public InteractiveSources Sources;
|
|
171
259
|
|
|
172
|
-
public
|
|
260
|
+
public bool IsShow = false;
|
|
261
|
+
public Texture2D Image => Sources.Get("test_inters");
|
|
262
|
+
public float HoldTime = 0;
|
|
263
|
+
|
|
264
|
+
public void Initialize(InteractiveSources sources)
|
|
173
265
|
{
|
|
174
|
-
|
|
175
|
-
BtnClose = root.Find("Inters/Layout/BtnClose").GetComponent<Button>();
|
|
176
|
-
BtnClose.onClick.AddListener(Hide);
|
|
177
|
-
Hide();
|
|
266
|
+
Sources = sources;
|
|
178
267
|
}
|
|
179
268
|
|
|
180
269
|
public void Show()
|
|
181
270
|
{
|
|
182
|
-
|
|
271
|
+
IsShow = true;
|
|
183
272
|
}
|
|
184
273
|
|
|
185
274
|
public void Hide()
|
|
186
275
|
{
|
|
187
|
-
|
|
276
|
+
IsShow = false;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
public void OnGUI(Rect rect, ScreenMode mode)
|
|
280
|
+
{
|
|
281
|
+
if (IsShow)
|
|
282
|
+
{
|
|
283
|
+
EditorGUI.DrawRect(rect, Color.black);
|
|
284
|
+
var size = CalculateImageMatchSize(Image, rect);
|
|
285
|
+
var imageRect = rect;
|
|
286
|
+
imageRect.width = size.x;
|
|
287
|
+
imageRect.height = size.y;
|
|
288
|
+
imageRect.center = rect.center;
|
|
289
|
+
GUI.DrawTexture(imageRect, Image);
|
|
290
|
+
|
|
291
|
+
var rectClose = imageRect;
|
|
292
|
+
rectClose.width = 246;
|
|
293
|
+
rectClose.height = 66;
|
|
294
|
+
rectClose.x = imageRect.xMax - rectClose.width - 10;
|
|
295
|
+
rectClose.y += 10;
|
|
296
|
+
DrawViewTxtLabel(rectClose, "关闭");
|
|
297
|
+
//悬停/关闭
|
|
298
|
+
HoldHide(rectClose, ref HoldTime, Hide);
|
|
299
|
+
|
|
300
|
+
var titleRect = imageRect;
|
|
301
|
+
titleRect.width = 400;
|
|
302
|
+
titleRect.height = 128;
|
|
303
|
+
titleRect.center = imageRect.center;
|
|
304
|
+
DrawViewTxtLabel(titleRect, "这是一个测试插页广告");
|
|
305
|
+
}
|
|
188
306
|
}
|
|
189
307
|
}
|
|
190
308
|
|
|
@@ -194,20 +312,18 @@ namespace TyphoonUnitySDK
|
|
|
194
312
|
|
|
195
313
|
public class VideoView
|
|
196
314
|
{
|
|
197
|
-
public
|
|
198
|
-
public
|
|
199
|
-
public Button BtnFail;
|
|
315
|
+
public InteractiveSources Sources;
|
|
316
|
+
public bool IsShow = false;
|
|
200
317
|
public Action OnSuccess;
|
|
201
318
|
public Action OnFail;
|
|
319
|
+
public Texture2D Image => Sources.Get("test_inters");
|
|
320
|
+
public float HoldTime = 0;
|
|
321
|
+
public float BtnYesHoldTime = 0;
|
|
322
|
+
public float BtnNoHoldTime = 0;
|
|
202
323
|
|
|
203
|
-
public void Initialize(
|
|
324
|
+
public void Initialize(InteractiveSources sources)
|
|
204
325
|
{
|
|
205
|
-
|
|
206
|
-
BtnSuccess = root.Find("Video/BtnSuccess").GetComponent<Button>();
|
|
207
|
-
BtnFail = root.Find("Video/BtnFail").GetComponent<Button>();
|
|
208
|
-
BtnSuccess.onClick.AddListener(OnClickSuccess);
|
|
209
|
-
BtnFail.onClick.AddListener(OnClickFail);
|
|
210
|
-
Hide();
|
|
326
|
+
Sources = sources;
|
|
211
327
|
}
|
|
212
328
|
|
|
213
329
|
public void OnClickSuccess()
|
|
@@ -226,13 +342,55 @@ namespace TyphoonUnitySDK
|
|
|
226
342
|
{
|
|
227
343
|
OnSuccess = success;
|
|
228
344
|
OnFail = fail;
|
|
229
|
-
|
|
345
|
+
IsShow = true;
|
|
230
346
|
}
|
|
231
347
|
|
|
232
348
|
|
|
233
349
|
public void Hide()
|
|
234
350
|
{
|
|
235
|
-
|
|
351
|
+
IsShow = false;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
public void OnGUI(Rect rect, ScreenMode mode)
|
|
355
|
+
{
|
|
356
|
+
if (IsShow)
|
|
357
|
+
{
|
|
358
|
+
EditorGUI.DrawRect(rect, Color.black);
|
|
359
|
+
var size = CalculateImageMatchSize(Image, rect);
|
|
360
|
+
var adRect = rect;
|
|
361
|
+
adRect.width = size.x;
|
|
362
|
+
adRect.height = size.y;
|
|
363
|
+
adRect.center = rect.center;
|
|
364
|
+
GUI.DrawTexture(adRect, Image);
|
|
365
|
+
|
|
366
|
+
var rectClose = adRect;
|
|
367
|
+
rectClose.width = 246;
|
|
368
|
+
rectClose.height = 66;
|
|
369
|
+
rectClose.x = adRect.xMax - rectClose.width - 10;
|
|
370
|
+
rectClose.y += 10;
|
|
371
|
+
DrawViewTxtLabel(rectClose, "关闭");
|
|
372
|
+
|
|
373
|
+
//成功返回
|
|
374
|
+
var rectYes = adRect;
|
|
375
|
+
rectYes.width = 346;
|
|
376
|
+
rectYes.height = 128;
|
|
377
|
+
rectYes.center = new Vector2(adRect.center.x, adRect.center.y + 80);
|
|
378
|
+
//失败返回
|
|
379
|
+
var rectNo = rectYes;
|
|
380
|
+
rectNo.center = new Vector2(adRect.center.x, adRect.center.y - 80);
|
|
381
|
+
DrawViewTxtLabel(rectYes, "成功返回");
|
|
382
|
+
DrawViewTxtLabel(rectNo, "失败返回");
|
|
383
|
+
HoldHide(rectYes, ref BtnYesHoldTime, OnClickSuccess);
|
|
384
|
+
HoldHide(rectNo, ref BtnNoHoldTime, OnClickFail);
|
|
385
|
+
HoldHide(rectClose, ref HoldTime, OnClickFail);
|
|
386
|
+
|
|
387
|
+
var rectTitle = adRect;
|
|
388
|
+
rectTitle.width = 400;
|
|
389
|
+
rectTitle.height = 128;
|
|
390
|
+
rectTitle.center = adRect.center;
|
|
391
|
+
rectTitle.y -= 300;
|
|
392
|
+
DrawViewTxtLabel(rectTitle, "这是一个测试视频");
|
|
393
|
+
}
|
|
236
394
|
}
|
|
237
395
|
}
|
|
238
396
|
|
|
@@ -242,37 +400,42 @@ namespace TyphoonUnitySDK
|
|
|
242
400
|
|
|
243
401
|
public class FloatIconView
|
|
244
402
|
{
|
|
245
|
-
public Transform View;
|
|
246
403
|
public Dictionary<string, FloatIconItem> Items = new Dictionary<string, FloatIconItem>();
|
|
247
|
-
public
|
|
248
|
-
|
|
249
|
-
public
|
|
404
|
+
public InteractiveSources Sources;
|
|
405
|
+
|
|
406
|
+
public static string[] ImageNames = new[]
|
|
407
|
+
{
|
|
408
|
+
"test_float_icon_1",
|
|
409
|
+
"test_float_icon_2",
|
|
410
|
+
"test_float_icon_4",
|
|
411
|
+
"test_float_icon_5",
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
public Texture2D Image
|
|
415
|
+
{
|
|
416
|
+
get
|
|
417
|
+
{
|
|
418
|
+
var index = (Items.Count + 1) % ImageNames.Length;
|
|
419
|
+
return Sources.Get(ImageNames[index]);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
250
422
|
|
|
251
|
-
public void Initialize(
|
|
423
|
+
public void Initialize(InteractiveSources sources)
|
|
252
424
|
{
|
|
253
|
-
|
|
254
|
-
Prefab = root.Find("FloatIcon").gameObject;
|
|
255
|
-
RangeMin = root.Find("RangeMin");
|
|
256
|
-
RangeMax = root.Find("RangeMax");
|
|
257
|
-
var prefabView = Prefab.GetComponent<CanvasGroup>();
|
|
258
|
-
SetViewValid(prefabView, false);
|
|
425
|
+
Sources = sources;
|
|
259
426
|
}
|
|
260
427
|
|
|
261
428
|
public void Show(string scene, float spx, float spy)
|
|
262
429
|
{
|
|
263
|
-
var x = Mathf.Lerp(RangeMin.position.x, RangeMax.position.x, spx);
|
|
264
|
-
var y = Mathf.Lerp(RangeMin.position.y, RangeMax.position.y, spy);
|
|
265
|
-
var pos = new Vector3(x, y, View.transform.position.z);
|
|
266
430
|
if (Items.TryGetValue(scene, out var match))
|
|
267
431
|
{
|
|
268
|
-
match.Show(
|
|
432
|
+
match.Show(new Vector2(spx, spy));
|
|
269
433
|
}
|
|
270
434
|
else
|
|
271
435
|
{
|
|
272
|
-
var
|
|
273
|
-
var item = FloatIconItem.Create(scene, clone);
|
|
436
|
+
var item = FloatIconItem.Create(scene, Image);
|
|
274
437
|
Items.Add(scene, item);
|
|
275
|
-
item.Show(
|
|
438
|
+
item.Show(new Vector2(spx, spy));
|
|
276
439
|
}
|
|
277
440
|
}
|
|
278
441
|
|
|
@@ -283,40 +446,59 @@ namespace TyphoonUnitySDK
|
|
|
283
446
|
match.Hide();
|
|
284
447
|
}
|
|
285
448
|
}
|
|
449
|
+
|
|
450
|
+
public void OnGUI(Rect rect, ScreenMode mode)
|
|
451
|
+
{
|
|
452
|
+
foreach (var item in Items.Values)
|
|
453
|
+
{
|
|
454
|
+
item.OnGUI(rect);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
286
457
|
}
|
|
287
458
|
|
|
288
459
|
public class FloatIconItem
|
|
289
460
|
{
|
|
461
|
+
public bool IsShow = false;
|
|
462
|
+
public Vector2 Sp;
|
|
463
|
+
public Texture2D Image;
|
|
290
464
|
public string SceneName;
|
|
291
|
-
public
|
|
292
|
-
public Button BtnClose;
|
|
465
|
+
public float HoldTime;
|
|
293
466
|
|
|
294
|
-
public static FloatIconItem Create(string scene,
|
|
467
|
+
public static FloatIconItem Create(string scene, Texture2D image)
|
|
295
468
|
{
|
|
296
469
|
var result = new FloatIconItem();
|
|
470
|
+
result.Image = image;
|
|
297
471
|
result.SceneName = scene;
|
|
298
|
-
result.View = prefab.GetComponent<CanvasGroup>();
|
|
299
|
-
result.Initialize();
|
|
300
472
|
return result;
|
|
301
473
|
}
|
|
302
474
|
|
|
303
|
-
public void
|
|
475
|
+
public void Hide()
|
|
304
476
|
{
|
|
305
|
-
|
|
306
|
-
BtnClose.onClick.AddListener(Hide);
|
|
477
|
+
IsShow = false;
|
|
307
478
|
}
|
|
308
479
|
|
|
309
|
-
|
|
310
|
-
public void Hide()
|
|
480
|
+
public void Show(Vector2 sp)
|
|
311
481
|
{
|
|
312
|
-
|
|
482
|
+
IsShow = true;
|
|
483
|
+
Sp = sp;
|
|
313
484
|
}
|
|
314
485
|
|
|
315
|
-
|
|
316
|
-
public void Show(Vector3 pos)
|
|
486
|
+
public void OnGUI(Rect rect)
|
|
317
487
|
{
|
|
318
|
-
|
|
319
|
-
|
|
488
|
+
if (IsShow)
|
|
489
|
+
{
|
|
490
|
+
var min = Mathf.Min(rect.height, rect.width);
|
|
491
|
+
var size = (int)(min * 0.1f);
|
|
492
|
+
var view = rect;
|
|
493
|
+
view.height = size;
|
|
494
|
+
view.width = size;
|
|
495
|
+
view.x = Mathf.Lerp(0, rect.width, Sp.x);
|
|
496
|
+
view.y = Mathf.Lerp(0, rect.width, Sp.y);
|
|
497
|
+
GUI.DrawTexture(view, Image);
|
|
498
|
+
var rectClose = view;
|
|
499
|
+
DrawViewTxtLabel(rectClose, "关闭", TextAnchor.UpperRight,0.3f);
|
|
500
|
+
HoldHide(rectClose, ref HoldTime, Hide);
|
|
501
|
+
}
|
|
320
502
|
}
|
|
321
503
|
}
|
|
322
504
|
|
|
@@ -326,28 +508,161 @@ namespace TyphoonUnitySDK
|
|
|
326
508
|
|
|
327
509
|
public class NativeView
|
|
328
510
|
{
|
|
329
|
-
public
|
|
330
|
-
public
|
|
511
|
+
public InteractiveSources Sources;
|
|
512
|
+
public bool IsShow = false;
|
|
513
|
+
public Texture2D Image => Sources.Get("test_native");
|
|
331
514
|
|
|
332
|
-
public
|
|
515
|
+
public float HoldTime = 0;
|
|
516
|
+
|
|
517
|
+
public void Initialize(InteractiveSources sources)
|
|
333
518
|
{
|
|
334
|
-
|
|
335
|
-
BtnClose = root.Find("Native/Mask/BtnClose").GetComponent<Button>();
|
|
336
|
-
BtnClose.onClick.AddListener(Hide);
|
|
337
|
-
Hide();
|
|
519
|
+
Sources = sources;
|
|
338
520
|
}
|
|
339
521
|
|
|
340
522
|
public void Show()
|
|
341
523
|
{
|
|
342
|
-
|
|
524
|
+
IsShow = true;
|
|
343
525
|
}
|
|
344
526
|
|
|
345
527
|
public void Hide()
|
|
346
528
|
{
|
|
347
|
-
|
|
529
|
+
IsShow = false;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
public void OnGUI(Rect rect, ScreenMode mode)
|
|
533
|
+
{
|
|
534
|
+
if (IsShow)
|
|
535
|
+
{
|
|
536
|
+
var heightScale = mode == ScreenMode.Portrait ? 0.4f : 0.8f;
|
|
537
|
+
var widthScale = mode == ScreenMode.Portrait ? 0.8f : 0.6f;
|
|
538
|
+
var height = heightScale * rect.height;
|
|
539
|
+
var width = widthScale * rect.width;
|
|
540
|
+
var view = rect;
|
|
541
|
+
view.height = height;
|
|
542
|
+
view.width = width;
|
|
543
|
+
var size = CalculateImageMatchSize(Image, view);
|
|
544
|
+
var imageRect = view;
|
|
545
|
+
imageRect.width = size.x;
|
|
546
|
+
imageRect.height = size.y;
|
|
547
|
+
imageRect.center = rect.center;
|
|
548
|
+
GUI.DrawTexture(imageRect, Image);
|
|
549
|
+
var rectClose = imageRect;
|
|
550
|
+
rectClose.width = 246;
|
|
551
|
+
rectClose.height = 66;
|
|
552
|
+
rectClose.x = imageRect.xMax - rectClose.width - 10;
|
|
553
|
+
rectClose.y += 10;
|
|
554
|
+
DrawViewTxtLabel(rectClose, "关闭");
|
|
555
|
+
HoldHide(rectClose, ref HoldTime, Hide);
|
|
556
|
+
|
|
557
|
+
var rectTitle = imageRect;
|
|
558
|
+
rectTitle.width = 400;
|
|
559
|
+
rectTitle.height = 128;
|
|
560
|
+
rectTitle.center = imageRect.center;
|
|
561
|
+
DrawViewTxtLabel(rectTitle, "这是一个测试原生广告");
|
|
562
|
+
}
|
|
348
563
|
}
|
|
349
564
|
}
|
|
350
565
|
|
|
351
566
|
#endregion
|
|
567
|
+
|
|
568
|
+
private ScreenMode GetMode()
|
|
569
|
+
{
|
|
570
|
+
return Screen.width - Screen.height > 0 ? ScreenMode.Landscape : ScreenMode.Portrait;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
private void OnGUI()
|
|
574
|
+
{
|
|
575
|
+
#if UNITY_EDITOR
|
|
576
|
+
|
|
577
|
+
var skin = GUI.skin;
|
|
578
|
+
GUI.skin = Skin;
|
|
579
|
+
var mode = GetMode();
|
|
580
|
+
var rect = new Rect(0, 0, Screen.width, Screen.height);
|
|
581
|
+
Banner.OnGUI(rect, mode);
|
|
582
|
+
FloatIcon.OnGUI(rect, mode);
|
|
583
|
+
Native.OnGUI(rect, mode);
|
|
584
|
+
Inters.OnGUI(rect, mode);
|
|
585
|
+
Video.OnGUI(rect, mode);
|
|
586
|
+
GUI.skin = skin;
|
|
587
|
+
#endif
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/// <summary>
|
|
591
|
+
/// 计算图片适配大小
|
|
592
|
+
/// </summary>
|
|
593
|
+
private static Vector2 CalculateImageMatchSize(Texture2D tex, Rect view)
|
|
594
|
+
{
|
|
595
|
+
var checkHeight = (view.width / tex.width) * tex.height;
|
|
596
|
+
if (checkHeight < view.height)
|
|
597
|
+
{
|
|
598
|
+
//以高为准,宽还有余量
|
|
599
|
+
return new Vector2(view.width, checkHeight);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
//以宽为准,高有余量
|
|
603
|
+
return new Vector2(view.height * tex.width / tex.height, view.height);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/*绘制文本*/
|
|
607
|
+
private static void DrawViewTxtLabel(Rect rect, string label, TextAnchor alignment = TextAnchor.MiddleCenter,
|
|
608
|
+
float dark = 0.75f)
|
|
609
|
+
{
|
|
610
|
+
EditorGUI.DrawRect(rect, Color.black * dark);
|
|
611
|
+
var rectLab = rect;
|
|
612
|
+
rectLab.width -= 10;
|
|
613
|
+
rectLab.height -= 10;
|
|
614
|
+
rectLab.center = rect.center;
|
|
615
|
+
UIStyles.BoldLabel.alignment = alignment;
|
|
616
|
+
GUI.Label(rectLab, label, UIStyles.BoldLabel);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/*长按隐藏*/
|
|
620
|
+
private static void HoldHide(Rect rectClose, ref float holdTime, Action hideHandler)
|
|
621
|
+
{
|
|
622
|
+
var inside = rectClose.Contains(Event.current.mousePosition);
|
|
623
|
+
if (inside && Event.current.delta == Vector2.zero)
|
|
624
|
+
{
|
|
625
|
+
holdTime += Time.unscaledDeltaTime;
|
|
626
|
+
var process = Mathf.Clamp01(holdTime / HOLD_TIME);
|
|
627
|
+
var rectProcess = rectClose;
|
|
628
|
+
rectProcess.width *= process;
|
|
629
|
+
EditorGUI.DrawRect(rectProcess, Color.green * 0.5f);
|
|
630
|
+
if (process >= 1)
|
|
631
|
+
{
|
|
632
|
+
hideHandler?.Invoke();
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
else
|
|
636
|
+
{
|
|
637
|
+
holdTime = 0;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
if (inside && Event.current.type == EventType.MouseDown)
|
|
641
|
+
{
|
|
642
|
+
hideHandler?.Invoke();
|
|
643
|
+
Event.current.Use();
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
public static Type GetType(string typeName)
|
|
649
|
+
{
|
|
650
|
+
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
|
651
|
+
foreach (var element in assemblies)
|
|
652
|
+
{
|
|
653
|
+
var types = element.GetTypes();
|
|
654
|
+
foreach (var type in types)
|
|
655
|
+
{
|
|
656
|
+
if (type.FullName == typeName)
|
|
657
|
+
{
|
|
658
|
+
return type;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
#endif
|
|
352
667
|
}
|
|
353
668
|
}
|