com.puzzlescapegames.services 1.0.2 → 1.0.5

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.
Files changed (75) hide show
  1. package/Editor/PuzzlescapeGames.Services.Editor.asmdef +3 -1
  2. package/README.md +5 -1
  3. package/Runtime/Common/AudioMixer.mixer +146 -0
  4. package/Runtime/Common/AudioMixer.mixer.meta +8 -0
  5. package/Runtime/Common.meta +8 -0
  6. package/Runtime/Plugins/SlicedFilledImage.cs +730 -0
  7. package/Runtime/Plugins/SlicedFilledImage.cs.meta +11 -0
  8. package/Runtime/Plugins/UIGradient/Editor/UIGradientEditor.cs +220 -0
  9. package/Runtime/Plugins/UIGradient/Editor/UIGradientEditor.cs.meta +11 -0
  10. package/Runtime/Plugins/UIGradient/Editor/uigradient_inspector_icon.png +0 -0
  11. package/Runtime/Plugins/UIGradient/Editor/uigradient_inspector_icon.png.meta +110 -0
  12. package/Runtime/Plugins/UIGradient/Editor.meta +8 -0
  13. package/Runtime/Plugins/UIGradient/Scripts/UIGradient.cs +511 -0
  14. package/Runtime/Plugins/UIGradient/Scripts/UIGradient.cs.meta +11 -0
  15. package/Runtime/Plugins/UIGradient/Scripts/Vector2Extension.cs +24 -0
  16. package/Runtime/Plugins/UIGradient/Scripts/Vector2Extension.cs.meta +11 -0
  17. package/Runtime/Plugins/UIGradient/Scripts.meta +8 -0
  18. package/Runtime/Plugins/UIGradient.meta +8 -0
  19. package/Runtime/Plugins/Vibration/Vibration/Example/VibrationExample.cs +82 -0
  20. package/Runtime/Plugins/Vibration/Vibration/Example/VibrationExample.cs.meta +11 -0
  21. package/Runtime/Plugins/Vibration/Vibration/Example.meta +8 -0
  22. package/Runtime/Plugins/Vibration/Vibration/Vibration.cs +263 -0
  23. package/Runtime/Plugins/Vibration/Vibration/Vibration.cs.meta +12 -0
  24. package/Runtime/Plugins/Vibration/Vibration.asmdef +18 -0
  25. package/Runtime/Plugins/Vibration/Vibration.asmdef.meta +7 -0
  26. package/Runtime/Plugins/Vibration/Vibration.meta +8 -0
  27. package/Runtime/Plugins/Vibration/iOS/HapticFeedback.mm +64 -0
  28. package/Runtime/Plugins/Vibration/iOS/HapticFeedback.mm.meta +37 -0
  29. package/Runtime/Plugins/Vibration/iOS/Vibration.h +26 -0
  30. package/Runtime/Plugins/Vibration/iOS/Vibration.h.meta +27 -0
  31. package/Runtime/Plugins/Vibration/iOS/Vibration.mm +73 -0
  32. package/Runtime/Plugins/Vibration/iOS/Vibration.mm.meta +37 -0
  33. package/Runtime/Plugins/Vibration/iOS.meta +8 -0
  34. package/Runtime/Plugins/Vibration.meta +8 -0
  35. package/Runtime/Plugins.meta +8 -0
  36. package/Runtime/PuzzlescapeGames.Services.asmdef +19 -2
  37. package/Runtime/Services/AudioService/AudioService.cs +82 -0
  38. package/Runtime/Services/AudioService/AudioService.cs.meta +3 -0
  39. package/Runtime/Services/AudioService/AudioServiceCustomInstaller.cs +29 -0
  40. package/Runtime/Services/AudioService/AudioServiceCustomInstaller.cs.meta +3 -0
  41. package/Runtime/Services/AudioService/AudioSource.cs +87 -0
  42. package/Runtime/Services/AudioService/AudioSource.cs.meta +3 -0
  43. package/Runtime/Services/AudioService/AudioSourceFactory.cs +6 -0
  44. package/Runtime/Services/AudioService/AudioSourceFactory.cs.meta +3 -0
  45. package/Runtime/Services/AudioService/IAudioService.cs +16 -0
  46. package/Runtime/Services/AudioService/IAudioService.cs.meta +3 -0
  47. package/Runtime/Services/AudioService.meta +8 -0
  48. package/Runtime/Services/NTPService/INTPService.cs +13 -0
  49. package/Runtime/Services/NTPService/INTPService.cs.meta +3 -0
  50. package/Runtime/Services/NTPService/NTPService.cs +153 -0
  51. package/Runtime/Services/NTPService/NTPService.cs.meta +3 -0
  52. package/Runtime/Services/NTPService/NTPServiceInstaller.cs +12 -0
  53. package/Runtime/Services/NTPService/NTPServiceInstaller.cs.meta +3 -0
  54. package/Runtime/Services/NTPService.meta +8 -0
  55. package/Runtime/Services/TickableService/TickableService.cs +29 -0
  56. package/Runtime/Services/TickableService/TickableService.cs.meta +3 -0
  57. package/Runtime/Services/TickableService/TickableServiceInstaller.cs +12 -0
  58. package/Runtime/Services/TickableService/TickableServiceInstaller.cs.meta +3 -0
  59. package/Runtime/Services/TickableService.meta +8 -0
  60. package/Runtime/Services/UIBlockingService/UIBlocker.cs +15 -0
  61. package/Runtime/Services/UIBlockingService/UIBlocker.cs.meta +3 -0
  62. package/Runtime/Services/UIBlockingService/UIBlockingService.cs +36 -0
  63. package/Runtime/Services/UIBlockingService/UIBlockingService.cs.meta +3 -0
  64. package/Runtime/Services/UIBlockingService/UIBlockingServiceInstaller.cs +17 -0
  65. package/Runtime/Services/UIBlockingService/UIBlockingServiceInstaller.cs.meta +3 -0
  66. package/Runtime/Services/UIBlockingService.meta +8 -0
  67. package/Runtime/Services/VibrationService/IVibrationService.cs +7 -0
  68. package/Runtime/Services/VibrationService/IVibrationService.cs.meta +3 -0
  69. package/Runtime/Services/VibrationService/VibrationService.cs +19 -0
  70. package/Runtime/Services/VibrationService/VibrationService.cs.meta +3 -0
  71. package/Runtime/Services/VibrationService/VibrationServiceInstaller.cs +12 -0
  72. package/Runtime/Services/VibrationService/VibrationServiceInstaller.cs.meta +3 -0
  73. package/Runtime/Services/VibrationService.meta +8 -0
  74. package/Runtime/Services.meta +8 -0
  75. package/package.json +1 -1
@@ -0,0 +1,511 @@
1
+ using JoshH.Extensions;
2
+ using UnityEngine;
3
+ using UnityEngine.UI;
4
+ using System.Collections.Generic;
5
+ using System.Linq;
6
+
7
+ /// <summary>
8
+ /// Author: Josh H.
9
+ /// Support: assetstore.joshh@gmail.com
10
+ /// </summary>
11
+
12
+ namespace JoshH.UI
13
+ {
14
+ [AddComponentMenu("UI/Effects/UI Gradient")]
15
+ [RequireComponent(typeof(RectTransform))]
16
+ public class UIGradient : BaseMeshEffect
17
+ {
18
+ [Tooltip("How the gradient color will be blended with the graphics color.")]
19
+ [SerializeField] private UIGradientBlendMode blendMode;
20
+
21
+ [SerializeField] [Range(0, 1)] private float intensity = 1f;
22
+
23
+ [SerializeField] private UIGradientType gradientType;
24
+
25
+ //Linear Colors
26
+ [SerializeField] private Color linearColor1 = Color.yellow;
27
+ [SerializeField] private Color linearColor2 = Color.red;
28
+
29
+ //Corner Colors
30
+ [SerializeField] private Color cornerColorUpperLeft = Color.red;
31
+ [SerializeField] private Color cornerColorUpperRight = Color.yellow;
32
+ [SerializeField] private Color cornerColorLowerRight = Color.green;
33
+ [SerializeField] private Color cornerColorLowerLeft = Color.blue;
34
+
35
+ //Complex Linear
36
+ [SerializeField] private Gradient linearGradient;
37
+
38
+ [SerializeField] [Range(0, 360)] private float angle;
39
+
40
+ private RectTransform _rectTransform;
41
+
42
+ protected RectTransform rectTransform
43
+ {
44
+ get
45
+ {
46
+ if (_rectTransform == null)
47
+ {
48
+ _rectTransform = transform as RectTransform;
49
+ }
50
+ return _rectTransform;
51
+ }
52
+ }
53
+
54
+ public UIGradientBlendMode BlendMode
55
+ {
56
+ get
57
+ {
58
+ return blendMode;
59
+ }
60
+
61
+ set
62
+ {
63
+ blendMode = value;
64
+ ForceUpdateGraphic();
65
+ }
66
+ }
67
+
68
+ public float Intensity
69
+ {
70
+ get
71
+ {
72
+ return intensity;
73
+ }
74
+
75
+ set
76
+ {
77
+ intensity = Mathf.Clamp01(value);
78
+ ForceUpdateGraphic();
79
+ }
80
+ }
81
+
82
+ public UIGradientType GradientType
83
+ {
84
+ get
85
+ {
86
+ return gradientType;
87
+ }
88
+
89
+ set
90
+ {
91
+ gradientType = value;
92
+ ForceUpdateGraphic();
93
+ }
94
+ }
95
+
96
+ public Color LinearColor1
97
+ {
98
+ get
99
+ {
100
+ return linearColor1;
101
+ }
102
+
103
+ set
104
+ {
105
+ linearColor1 = value;
106
+ ForceUpdateGraphic();
107
+ }
108
+ }
109
+
110
+ public Color LinearColor2
111
+ {
112
+ get
113
+ {
114
+ return linearColor2;
115
+ }
116
+
117
+ set
118
+ {
119
+ linearColor2 = value;
120
+ ForceUpdateGraphic();
121
+ }
122
+ }
123
+
124
+ public Color CornerColorUpperLeft
125
+ {
126
+ get
127
+ {
128
+ return cornerColorUpperLeft;
129
+ }
130
+
131
+ set
132
+ {
133
+ cornerColorUpperLeft = value;
134
+ ForceUpdateGraphic();
135
+ }
136
+ }
137
+
138
+ public Color CornerColorUpperRight
139
+ {
140
+ get
141
+ {
142
+ return cornerColorUpperRight;
143
+ }
144
+
145
+ set
146
+ {
147
+ cornerColorUpperRight = value;
148
+ ForceUpdateGraphic();
149
+ }
150
+ }
151
+
152
+ public Color CornerColorLowerRight
153
+ {
154
+ get
155
+ {
156
+ return cornerColorLowerRight;
157
+ }
158
+
159
+ set
160
+ {
161
+ cornerColorLowerRight = value;
162
+ ForceUpdateGraphic();
163
+ }
164
+ }
165
+
166
+ public Color CornerColorLowerLeft
167
+ {
168
+ get
169
+ {
170
+ return cornerColorLowerLeft;
171
+ }
172
+
173
+ set
174
+ {
175
+ cornerColorLowerLeft = value;
176
+ ForceUpdateGraphic();
177
+ }
178
+ }
179
+
180
+ public float Angle
181
+ {
182
+ get
183
+ {
184
+ return angle;
185
+ }
186
+
187
+ set
188
+ {
189
+ if (value < 0)
190
+ {
191
+ angle = (value % 360) + 360;
192
+ }
193
+ else
194
+ {
195
+ angle = value % 360;
196
+ }
197
+ ForceUpdateGraphic();
198
+ }
199
+ }
200
+
201
+ public Gradient LinearGradient
202
+ {
203
+ get
204
+ {
205
+ return linearGradient;
206
+ }
207
+
208
+ set
209
+ {
210
+ linearGradient = value;
211
+ ForceUpdateGraphic();
212
+ }
213
+ }
214
+
215
+ public override void ModifyMesh(VertexHelper vh)
216
+ {
217
+ if (this.enabled)
218
+ {
219
+ UIVertex vert = new UIVertex();
220
+ if (gradientType == UIGradientType.ComplexLinear)
221
+ {
222
+ CutMesh(vh);
223
+ }
224
+
225
+ for (int i = 0; i < vh.currentVertCount; i++)
226
+ {
227
+ vh.PopulateUIVertex(ref vert, i);
228
+
229
+ #if UNITY_2018_1_OR_NEWER
230
+ Vector2 normalizedPosition = ((Vector2)vert.position - rectTransform.rect.min) / (rectTransform.rect.max - rectTransform.rect.min);
231
+ #else
232
+ Vector2 size = rectTransform.rect.max - rectTransform.rect.min;
233
+ Vector2 normalizedPosition = Vector2.Scale((Vector2)vert.position - rectTransform.rect.min, new Vector2(1f / size.x, 1f / size.y));
234
+ #endif
235
+
236
+ normalizedPosition = RotateNormalizedPosition(normalizedPosition, this.angle);
237
+
238
+ //get color with selected gradient type
239
+ Color gradientColor = Color.black;
240
+ if (gradientType == UIGradientType.Linear)
241
+ {
242
+ gradientColor = GetColorInGradient(linearColor1, linearColor1, linearColor2, linearColor2, normalizedPosition);
243
+ }
244
+ else if (gradientType == UIGradientType.Corner)
245
+ {
246
+ gradientColor = GetColorInGradient(cornerColorUpperLeft, cornerColorUpperRight, cornerColorLowerRight, cornerColorLowerLeft, normalizedPosition);
247
+ }
248
+ else if (gradientType == UIGradientType.ComplexLinear)
249
+ {
250
+ gradientColor = linearGradient.Evaluate(normalizedPosition.y);
251
+ }
252
+ vert.color = BlendColor(vert.color, gradientColor, blendMode, intensity);
253
+ vh.SetUIVertex(vert, i);
254
+ }
255
+ }
256
+ }
257
+
258
+ protected void CutMesh(VertexHelper vh)
259
+ {
260
+ var tris = new List<UIVertex>();
261
+
262
+ vh.GetUIVertexStream(tris);
263
+
264
+ vh.Clear();
265
+
266
+ var list = new List<UIVertex>();
267
+
268
+ var d = GetCutDirection();
269
+
270
+ IEnumerable<float> cuts = linearGradient.alphaKeys.Select(x => { return x.time; });
271
+ cuts = cuts.Union(linearGradient.colorKeys.Select(x => { return x.time; }));
272
+
273
+ foreach (var item in cuts)
274
+ {
275
+ list.Clear();
276
+ var point = GetCutOrigin(item);
277
+ if (item < 0.001 || item > 0.999)
278
+ {
279
+ continue;
280
+ }
281
+ else
282
+ {
283
+ for (int j = 0; j < tris.Count; j += 3)
284
+ {
285
+ CutTriangle(tris, j, list, d, point);
286
+ }
287
+ }
288
+ tris.Clear();
289
+ tris.AddRange(list);
290
+ }
291
+ vh.AddUIVertexTriangleStream(tris);
292
+ }
293
+
294
+ UIVertex UIVertexLerp(UIVertex v1, UIVertex v2, float f)
295
+ {
296
+ UIVertex vert = new UIVertex();
297
+
298
+ vert.position = Vector3.Lerp(v1.position, v2.position, f);
299
+ vert.color = Color.Lerp(v1.color, v2.color, f);
300
+ vert.uv0 = Vector2.Lerp(v1.uv0, v2.uv0, f);
301
+ vert.uv1 = Vector2.Lerp(v1.uv1, v2.uv1, f);
302
+ vert.uv2 = Vector2.Lerp(v1.uv2, v2.uv2, f);
303
+ vert.uv3 = Vector2.Lerp(v1.uv3, v2.uv3, f);
304
+
305
+ return vert;
306
+ }
307
+
308
+ Vector2 GetCutDirection()
309
+ {
310
+ var v = Vector2.up.Rotate(-angle);
311
+ v = new Vector2(v.x / this.rectTransform.rect.size.x,v.y / this.rectTransform.rect.size.y);
312
+ return v.Rotate(90);
313
+ }
314
+
315
+ void CutTriangle(List<UIVertex> tris, int idx, List<UIVertex> list, Vector2 cutDirection, Vector2 point)
316
+ {
317
+ var a = tris[idx];
318
+ var b = tris[idx + 1];
319
+ var c = tris[idx + 2];
320
+
321
+ float bc = OnLine(b.position, c.position, point, cutDirection);
322
+ float ab = OnLine(a.position, b.position, point, cutDirection);
323
+ float ca = OnLine(c.position, a.position, point, cutDirection);
324
+
325
+ if (IsOnLine(ab))
326
+ {
327
+ if (IsOnLine(bc))
328
+ {
329
+ var pab = UIVertexLerp(a, b, ab);
330
+ var pbc = UIVertexLerp(b, c, bc);
331
+ list.AddRange(new List<UIVertex>() { a, pab, c, pab, pbc, c, pab, b, pbc });
332
+ }
333
+ else
334
+ {
335
+ var pab = UIVertexLerp(a, b, ab);
336
+ var pca = UIVertexLerp(c, a, ca);
337
+ list.AddRange(new List<UIVertex>() { c, pca, b, pca, pab, b, pca, a, pab });
338
+ }
339
+ }
340
+ else if (IsOnLine(bc))
341
+ {
342
+ var pbc = UIVertexLerp(b, c, bc);
343
+ var pca = UIVertexLerp(c, a, ca);
344
+ list.AddRange(new List<UIVertex>() { b, pbc, a, pbc, pca, a, pbc, c, pca });
345
+ }
346
+ else
347
+ {
348
+ list.AddRange(tris.GetRange(idx, 3));
349
+ }
350
+ }
351
+
352
+ bool IsOnLine(float f)
353
+ {
354
+ return f <= 1 && f > 0;
355
+ }
356
+
357
+ /// <summary>
358
+ /// Calculates intersection of two lines.
359
+ /// </summary>
360
+ /// <param name="p1">Point on line 1</param>
361
+ /// <param name="p2">Point on line 1</param>
362
+ /// <param name="o">Point on line 2</param>
363
+ /// <param name="dir">Direction of line 2</param>
364
+ /// <returns>f: lerp(p1,p2,f) is the point of intersection</returns>
365
+ float OnLine(Vector2 p1, Vector2 p2, Vector2 o, Vector2 dir)
366
+ {
367
+ float tmp = (p2.x - p1.x) * dir.y - (p2.y - p1.y) * dir.x;
368
+ if (tmp == 0)
369
+ {
370
+ return -1;
371
+ }
372
+ float mu = ((o.x - p1.x) * dir.y - (o.y - p1.y) * dir.x) / tmp;
373
+ return mu;
374
+ }
375
+
376
+ float ProjectedDistance(Vector2 p1, Vector2 p2, Vector2 normal)
377
+ {
378
+ return Vector2.Distance(Vector3.Project(p1, normal), Vector3.Project(p2, normal));
379
+ }
380
+
381
+ Vector2 GetCutOrigin(float f)
382
+ {
383
+ var v = Vector2.up.Rotate(-angle);
384
+
385
+ v = new Vector2(v.x / this.rectTransform.rect.size.x,v.y / this.rectTransform.rect.size.y);
386
+
387
+ Vector3 p1, p2;
388
+
389
+ if (angle % 180 < 90)
390
+ {
391
+ p1 = Vector3.Project(Vector2.Scale(rectTransform.rect.size, (Vector2.down + Vector2.left)) * 0.5f, v);
392
+ p2 = Vector3.Project(Vector2.Scale(rectTransform.rect.size,(Vector2.up + Vector2.right)) * 0.5f, v);
393
+ }
394
+ else
395
+ {
396
+ p1 = Vector3.Project(Vector2.Scale(rectTransform.rect.size,(Vector2.up + Vector2.left)) * 0.5f, v);
397
+ p2 = Vector3.Project(Vector2.Scale(rectTransform.rect.size,(Vector2.down + Vector2.right)) * 0.5f, v);
398
+ }
399
+ if (angle % 360 >= 180)
400
+ {
401
+ return Vector2.Lerp(p2, p1, f) + rectTransform.rect.center;
402
+ }
403
+ else
404
+ {
405
+ return Vector2.Lerp(p1, p2, f) + rectTransform.rect.center;
406
+ }
407
+ }
408
+
409
+ private Color BlendColor(Color c1, Color c2, UIGradientBlendMode mode, float intensity)
410
+ {
411
+ if (mode == UIGradientBlendMode.Override)
412
+ {
413
+ return Color.Lerp(c1, c2, intensity);
414
+ }
415
+ else if (mode == UIGradientBlendMode.Multiply)
416
+ {
417
+ return Color.Lerp(c1, c1 * c2, intensity);
418
+ }
419
+ else
420
+ {
421
+ Debug.LogErrorFormat("Mode is not supported: {0}", mode);
422
+ return c1;
423
+ }
424
+ }
425
+
426
+ /// <summary>
427
+ /// Rotates a position in with coordinates in [0,1]
428
+ /// </summary>
429
+ /// <param name="normalizedPosition">Point to rotate</param>
430
+ /// <param name="angle">Angle to rotate in degrees</param>
431
+ /// <returns>Rotated point</returns>
432
+ private Vector2 RotateNormalizedPosition(Vector2 normalizedPosition, float angle)
433
+ {
434
+ float a = Mathf.Deg2Rad * (angle < 0 ? (angle % 90 + 90) : (angle % 90));
435
+ float scale = Mathf.Sin(a) + Mathf.Cos(a);
436
+
437
+ return (normalizedPosition - Vector2.one * 0.5f).Rotate(angle) / scale + Vector2.one * 0.5f;
438
+ }
439
+
440
+ /// <summary>
441
+ /// Sets vertices of the referenced Graphic dirty. This triggers a new mesh generation and modification.
442
+ /// </summary>
443
+ public void ForceUpdateGraphic()
444
+ {
445
+ if (this.graphic != null)
446
+ {
447
+ this.graphic.SetVerticesDirty();
448
+ }
449
+ }
450
+
451
+ /// <summary>
452
+ /// Calculates color interpolated between 4 corners.
453
+ /// </summary>
454
+ /// <param name="ul">upper left (0,1)</param>
455
+ /// <param name="ur">upper right (1,1)</param>
456
+ /// <param name="lr">lower right (1,0)</param>
457
+ /// <param name="ll">lower left (0,0)</param>
458
+ /// <param name="normalizedPosition">position (x,y) in [0,1]</param>
459
+ /// <returns>interpolated color</returns>
460
+ private Color GetColorInGradient(Color ul, Color ur, Color lr, Color ll, Vector2 normalizedPosition)
461
+ {
462
+ return Color.Lerp(Color.Lerp(ll, lr, normalizedPosition.x), Color.Lerp(ul, ur, normalizedPosition.x), normalizedPosition.y); ;
463
+ }
464
+
465
+ public enum UIGradientBlendMode
466
+ {
467
+ Override,
468
+ Multiply
469
+ }
470
+
471
+ public enum UIGradientType
472
+ {
473
+ Linear,
474
+ Corner,
475
+ ComplexLinear
476
+ }
477
+
478
+ #if UNITY_EDITOR
479
+ /// <summary>
480
+ /// Reset is called when the user hits the Reset button in the Inspector's
481
+ /// context menu or when adding the component the first time.
482
+ /// </summary>
483
+ protected override void Reset()
484
+ {
485
+ base.Reset();
486
+
487
+ this.linearGradient = new Gradient();
488
+
489
+ // Populate the color keys
490
+ var colorKey = new GradientColorKey[3];
491
+ colorKey[0].color = new Color(0.5137255f, 0.2274510f, 0.7058824f);
492
+ colorKey[0].time = 0.0f;
493
+ colorKey[1].color = new Color(0.9921569f, 0.1137255f, 0.1137255f);
494
+ colorKey[1].time = 0.5f;
495
+ colorKey[2].color = new Color(0.9882353f, 0.6901961f, 0.2705882f);
496
+ colorKey[2].time = 1.0f;
497
+
498
+ // Populate the alpha keys
499
+ var alphaKey = new GradientAlphaKey[2];
500
+ alphaKey[0].alpha = 1.0f;
501
+ alphaKey[0].time = 0.0f;
502
+ alphaKey[1].alpha = 1.0f;
503
+ alphaKey[1].time = 1.0f;
504
+
505
+ this.linearGradient.SetKeys(colorKey, alphaKey);
506
+
507
+ ForceUpdateGraphic();
508
+ }
509
+ #endif
510
+ }
511
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: e68f7d540fbfa754e91fff56d9bd2af1
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {fileID: 2800000, guid: 8ee3c2bc119f3b9488972e189bdcd023, type: 3}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,24 @@
1
+ using UnityEngine;
2
+
3
+ /// <summary>
4
+ /// Author: Josh H.
5
+ /// Support: assetstore.joshh@gmail.com
6
+ /// </summary>
7
+
8
+ namespace JoshH.Extensions
9
+ {
10
+ public static class Vector2Extension
11
+ {
12
+ public static Vector2 Rotate(this Vector2 v, float degrees)
13
+ {
14
+ float sin = Mathf.Sin(degrees * Mathf.Deg2Rad);
15
+ float cos = Mathf.Cos(degrees * Mathf.Deg2Rad);
16
+
17
+ float tx = v.x;
18
+ float ty = v.y;
19
+ v.x = (cos * tx) - (sin * ty);
20
+ v.y = (sin * tx) + (cos * ty);
21
+ return v;
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: abaa885930aa9bf4ab33943ff6eb20c6
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: f743f18293088bd4e991b5bf005f9ab0
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 5d2e002eed0764f4ba09d0d1b4c5484f
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,82 @@
1
+ ////////////////////////////////////////////////////////////////////////////////
2
+ //
3
+ // @author Benoît Freslon @benoitfreslon
4
+ // https://github.com/BenoitFreslon/Vibration
5
+ // https://benoitfreslon.com
6
+ //
7
+ ////////////////////////////////////////////////////////////////////////////////
8
+
9
+ using System;
10
+ using System.Collections;
11
+ using System.Collections.Generic;
12
+ using System.Linq;
13
+ using UnityEngine;
14
+ using UnityEngine.UI;
15
+
16
+ public class VibrationExample : MonoBehaviour
17
+ {
18
+ public Text inputTime;
19
+ public Text inputPattern;
20
+ public Text inputRepeat;
21
+ public Text txtAndroidVersion;
22
+
23
+ // Use this for initialization
24
+ void Start ()
25
+ {
26
+ Vibration.Init ();
27
+ Debug.Log ( "Application.isMobilePlatform: " + Application.isMobilePlatform );
28
+ txtAndroidVersion.text = "Android Version: " + Vibration.AndroidVersion.ToString ();
29
+ }
30
+
31
+ // Update is called once per frame
32
+ void Update ()
33
+ {
34
+
35
+ }
36
+
37
+ public void TapVibrate ()
38
+ {
39
+ Vibration.Vibrate ();
40
+ }
41
+
42
+ public void TapVibrateCustom ()
43
+ {
44
+ #if UNITY_ANDROID
45
+ Vibration.VibrateAndroid ( int.Parse ( inputTime.text ) );
46
+ #endif
47
+ }
48
+
49
+ public void TapVibratePattern ()
50
+ {
51
+ string[] patterns = inputPattern.text.Replace ( " ", "" ).Split ( ',' );
52
+ long[] longs = Array.ConvertAll<string, long> ( patterns, long.Parse );
53
+
54
+ Debug.Log ( longs.Length );
55
+ //Vibration.Vibrate ( longs, int.Parse ( inputRepeat.text ) );
56
+ #if UNITY_ANDROID
57
+ Vibration.VibrateAndroid ( longs, int.Parse ( inputRepeat.text ) );
58
+ #endif
59
+ }
60
+
61
+ public void TapCancelVibrate ()
62
+ {
63
+ #if UNITY_ANDROID
64
+ Vibration.CancelAndroid();
65
+ #endif
66
+ }
67
+
68
+ public void TapPopVibrate ()
69
+ {
70
+ Vibration.VibratePop ();
71
+ }
72
+
73
+ public void TapPeekVibrate ()
74
+ {
75
+ Vibration.VibratePeek ();
76
+ }
77
+
78
+ public void TapNopeVibrate ()
79
+ {
80
+ Vibration.VibrateNope ();
81
+ }
82
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: d1969ec4ca0394b3d96ed889fdfcd19e
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: a46eaded73024424bb1659e2b9eeee69
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant: