com.typhoon.unitysdk 1.0.39 → 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.
@@ -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
  }
@@ -244,7 +244,7 @@ namespace TyphoonUnitySDK
244
244
  #if UNITY_EDITOR
245
245
  if (SdkTestInUnity.Instance.OpenInteractive)
246
246
  {
247
- SDKInteractiveUI.Instance.ShowInters();
247
+ SDKInteractiveUI.Instance.ShowInters(scene);
248
248
  return;
249
249
  }
250
250
 
package/package.json CHANGED
@@ -1 +1 @@
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"}}
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"}}