app.hypergames.hypersdk 1.4.22 → 1.5.1

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.
@@ -52,6 +52,9 @@ namespace Hyper.Internal
52
52
  private const float DARK_THEME_PAUSE_BUTTON_ALPHA = 0.25f;
53
53
  private const float LIGHT_THEME_PAUSE_BUTTON_ALPHA = 1f;
54
54
 
55
+ private int lastScore = -1;
56
+ private readonly char[] _scoreBuffer = new char[16];
57
+
55
58
  void Awake()
56
59
  {
57
60
  _gameManager = HyperRuntime.GameManager;
@@ -260,7 +263,12 @@ namespace Hyper.Internal
260
263
 
261
264
  public void UpdateScoreLabel()
262
265
  {
263
- scoreText.SetText(HyperRuntime.DataManager.CurrentScore.ToString("N0"));
266
+ int currentScore = HyperRuntime.DataManager.CurrentScore;
267
+ if (currentScore != lastScore)
268
+ {
269
+ lastScore = currentScore;
270
+ HyperNumberFormatter.SetScoreNoAlloc(_scoreTextComponent, currentScore, _scoreBuffer);
271
+ }
264
272
  }
265
273
 
266
274
  /// <summary>
@@ -3,6 +3,7 @@ using UnityEngine;
3
3
  using TMPro;
4
4
  using UnityEngine.UI;
5
5
  using Hyper.Internal.Animation;
6
+ using System.Text;
6
7
 
7
8
  namespace Hyper.Internal
8
9
  {
@@ -33,6 +34,7 @@ namespace Hyper.Internal
33
34
  private int _maxLives;
34
35
  private Image[] _heartImages;
35
36
  private bool _livesExhaustedTriggered;
37
+ private readonly StringBuilder _overflowLabelText = new StringBuilder(10);
36
38
 
37
39
  private void Awake()
38
40
  {
@@ -311,16 +313,13 @@ namespace Hyper.Internal
311
313
 
312
314
  int heartSlots = _heartImages != null ? _heartImages.Length : 0;
313
315
  int overflow = Mathf.Max(0, _currentLives - heartSlots);
316
+
314
317
  if (overflow > 0)
315
318
  {
316
- overflowLabel.gameObject.SetActive(true);
317
- overflowLabel.text = $"+{overflow}";
318
- }
319
- else
320
- {
321
- overflowLabel.text = string.Empty;
322
- overflowLabel.gameObject.SetActive(false);
319
+ overflowLabel.SetText("+{0}", overflow);
323
320
  }
321
+
322
+ overflowLabel.gameObject.SetActive(overflow > 0);
324
323
  }
325
324
  }
326
325
  }
@@ -19,7 +19,7 @@ namespace Hyper.Internal
19
19
  int seconds = Mathf.FloorToInt(HyperRuntime.Timer.CurrentTime % 60);
20
20
 
21
21
  // Update the UI text to display in the format 00:00
22
- timerText.text = string.Format("{0:00}:{1:00}", minutes, seconds);
22
+ timerText.SetText("{0:00}:{1:00}", minutes, seconds);
23
23
 
24
24
  }
25
25
  }
@@ -104,11 +104,16 @@ namespace Hyper.Internal
104
104
  // Called from the SlideRight script once the animation is finished
105
105
  public void StartAction()
106
106
  {
107
- StartLerpingSlider(0.75f, HyperRuntime.BackendManager.scoreSubmissionTimeout);
107
+ StartLerpingSlider(0.6f, HyperRuntime.BackendManager.scoreSubmissionTimeout);
108
108
  }
109
109
 
110
110
  public void ScoreHasBeenSubmitted()
111
111
  {
112
+ // Change back to "Submitting score" since submission is now successful
113
+ // and we're just loading to completion
114
+ if (scoreSubmissionText != null)
115
+ scoreSubmissionText.text = "Submitting score";
116
+
112
117
  StopLerpingSlider();
113
118
  StartCoroutine(SetLoadingBarComplete());
114
119
  }
@@ -17,11 +17,13 @@ namespace Hyper.Internal
17
17
  [SerializeField] private TextMeshProUGUI startCtaLabel;
18
18
  [SerializeField] private BlinkingText blinkingText;
19
19
  [SerializeField] private RectTransform swipeGif;
20
+ [SerializeField] private RectTransform handSpriteInGif;
20
21
  private EventManager _eventManager;
21
22
  private DataManager _dataManager;
22
23
  private GameManager _gameManager;
23
24
  private BackendManager _backendManager;
24
25
  private StartCTA _currentCTA;
26
+ private SwipeDirection _swipeDirection;
25
27
 
26
28
  // Swipe detection variables
27
29
  private Vector2 _swipeStartPosition;
@@ -56,6 +58,9 @@ namespace Hyper.Internal
56
58
  public void Configure(StartCTA cta)
57
59
  {
58
60
  _currentCTA = cta;
61
+ _swipeDirection = HyperRuntime.Settings != null
62
+ ? HyperRuntime.Settings.swipeDirection
63
+ : SwipeDirection.Up;
59
64
 
60
65
  if (startCtaLabel == null)
61
66
  {
@@ -151,7 +156,7 @@ namespace Hyper.Internal
151
156
  {
152
157
  currentPosition = Input.mousePosition;
153
158
  Vector2 delta = currentPosition - _swipeStartPosition;
154
-
159
+
155
160
  if (IsSwipeDirectionValid(delta))
156
161
  {
157
162
  swipeDetected = true;
@@ -167,7 +172,7 @@ namespace Hyper.Internal
167
172
  if (Input.touchCount > 0)
168
173
  {
169
174
  Touch touch = Input.GetTouch(0);
170
-
175
+
171
176
  if (touch.phase == TouchPhase.Began)
172
177
  {
173
178
  _swipeStartPosition = touch.position;
@@ -177,7 +182,7 @@ namespace Hyper.Internal
177
182
  {
178
183
  currentPosition = touch.position;
179
184
  Vector2 delta = currentPosition - _swipeStartPosition;
180
-
185
+
181
186
  if (IsSwipeDirectionValid(delta))
182
187
  {
183
188
  swipeDetected = true;
@@ -276,27 +281,53 @@ namespace Hyper.Internal
276
281
 
277
282
  private void UpdateSwipeGraphics()
278
283
  {
279
- bool showVertical = _currentCTA == StartCTA.SwipeToPlayVertical;
280
- bool showHorizontal = _currentCTA == StartCTA.SwipeToPlayHorizontal;
281
-
282
284
  if (swipeGif != null)
283
285
  {
284
- if (showVertical)
285
- {
286
- swipeGif.anchoredPosition = new Vector3(0, 286, 0);
287
- swipeGif.transform.rotation = Quaternion.Euler(0, 0, 90);
288
- swipeGif.gameObject.SetActive(true);
289
- }
290
- else if (showHorizontal)
286
+ bool isSwipe =
287
+ _currentCTA == StartCTA.SwipeToPlayVertical ||
288
+ _currentCTA == StartCTA.SwipeToPlayHorizontal;
289
+
290
+ if (!isSwipe)
291
291
  {
292
- swipeGif.anchoredPosition = new Vector3(0, 220, 0);
293
- swipeGif.transform.rotation = Quaternion.Euler(0, 0, 0);
294
- swipeGif.gameObject.SetActive(true);
292
+ swipeGif.gameObject.SetActive(false);
293
+ return;
295
294
  }
296
- else
295
+
296
+ // Default positions based on axis (vertical vs horizontal)
297
+ Vector3 verticalPosition = new Vector3(0, 286, 0);
298
+ Vector3 horizontalPosition = new Vector3(0, 220, 0);
299
+
300
+ float rotationZ;
301
+ Vector3 anchoredPosition;
302
+
303
+ switch (_swipeDirection)
297
304
  {
298
- swipeGif.gameObject.SetActive(false);
305
+ case SwipeDirection.Up:
306
+ rotationZ = 90f;
307
+ anchoredPosition = verticalPosition;
308
+ break;
309
+ case SwipeDirection.Down:
310
+ rotationZ = -90f;
311
+ anchoredPosition = verticalPosition;
312
+ handSpriteInGif.anchoredPosition = new Vector2(0, 40);
313
+ handSpriteInGif.transform.rotation = Quaternion.Euler(-180, 180, 0);
314
+ break;
315
+ case SwipeDirection.Left:
316
+ rotationZ = 180f;
317
+ anchoredPosition = horizontalPosition;
318
+ handSpriteInGif.anchoredPosition = new Vector2(0, 40);
319
+ handSpriteInGif.transform.rotation = Quaternion.Euler(0, 0, 180);
320
+ break;
321
+ case SwipeDirection.Right:
322
+ default:
323
+ rotationZ = 0f;
324
+ anchoredPosition = horizontalPosition;
325
+ break;
299
326
  }
327
+
328
+ swipeGif.anchoredPosition = anchoredPosition;
329
+ swipeGif.transform.rotation = Quaternion.Euler(0, 0, rotationZ);
330
+ swipeGif.gameObject.SetActive(true);
300
331
  }
301
332
  }
302
333
 
@@ -305,12 +336,16 @@ namespace Hyper.Internal
305
336
  float absX = Mathf.Abs(delta.x);
306
337
  float absY = Mathf.Abs(delta.y);
307
338
 
308
- switch (_currentCTA)
339
+ switch (_swipeDirection)
309
340
  {
310
- case StartCTA.SwipeToPlayVertical:
311
- return absY >= SWIPE_THRESHOLD && absY >= absX;
312
- case StartCTA.SwipeToPlayHorizontal:
313
- return absX >= SWIPE_THRESHOLD && absX >= absY;
341
+ case SwipeDirection.Up:
342
+ return delta.y >= SWIPE_THRESHOLD && absY >= absX;
343
+ case SwipeDirection.Down:
344
+ return -delta.y >= SWIPE_THRESHOLD && absY >= absX;
345
+ case SwipeDirection.Right:
346
+ return delta.x >= SWIPE_THRESHOLD && absX >= absY;
347
+ case SwipeDirection.Left:
348
+ return -delta.x >= SWIPE_THRESHOLD && absX >= absY;
314
349
  default:
315
350
  return false;
316
351
  }
@@ -17,6 +17,7 @@ MonoBehaviour:
17
17
  pc: 0
18
18
  mobile: 1
19
19
  startCTA: 0
20
+ swipeDirection: 0
20
21
  controlBarLayout: 0
21
22
  controlBarTheme: 1
22
23
  useCustomRestartFlow: 0
@@ -23,7 +23,7 @@ AnimationClip:
23
23
  m_Curve:
24
24
  - serializedVersion: 3
25
25
  time: 0
26
- value: -110
26
+ value: -80
27
27
  inSlope: 0
28
28
  outSlope: 0
29
29
  tangentMode: 136
@@ -31,8 +31,8 @@ AnimationClip:
31
31
  inWeight: 0.33333334
32
32
  outWeight: 0.33333334
33
33
  - serializedVersion: 3
34
- time: 0.5714286
35
- value: 100
34
+ time: 0.42857143
35
+ value: 80
36
36
  inSlope: 0
37
37
  outSlope: 0
38
38
  tangentMode: 136
@@ -40,8 +40,8 @@ AnimationClip:
40
40
  inWeight: 0.33333334
41
41
  outWeight: 0.33333334
42
42
  - serializedVersion: 3
43
- time: 0.85714287
44
- value: 100
43
+ time: 0.71428573
44
+ value: 80
45
45
  inSlope: 0
46
46
  outSlope: 0
47
47
  tangentMode: 136
@@ -49,8 +49,8 @@ AnimationClip:
49
49
  inWeight: 0.33333334
50
50
  outWeight: 0.33333334
51
51
  - serializedVersion: 3
52
- time: 1.4285715
53
- value: -110
52
+ time: 1.2857143
53
+ value: -80
54
54
  inSlope: 0
55
55
  outSlope: 0
56
56
  tangentMode: 136
@@ -88,7 +88,7 @@ AnimationClip:
88
88
  m_AdditiveReferencePoseClip: {fileID: 0}
89
89
  m_AdditiveReferencePoseTime: 0
90
90
  m_StartTime: 0
91
- m_StopTime: 1.4285715
91
+ m_StopTime: 1.2857143
92
92
  m_OrientationOffsetY: 0
93
93
  m_Level: 0
94
94
  m_CycleOffset: 0
@@ -110,7 +110,7 @@ AnimationClip:
110
110
  m_Curve:
111
111
  - serializedVersion: 3
112
112
  time: 0
113
- value: -110
113
+ value: -80
114
114
  inSlope: 0
115
115
  outSlope: 0
116
116
  tangentMode: 136
@@ -118,8 +118,8 @@ AnimationClip:
118
118
  inWeight: 0.33333334
119
119
  outWeight: 0.33333334
120
120
  - serializedVersion: 3
121
- time: 0.5714286
122
- value: 100
121
+ time: 0.42857143
122
+ value: 80
123
123
  inSlope: 0
124
124
  outSlope: 0
125
125
  tangentMode: 136
@@ -127,8 +127,8 @@ AnimationClip:
127
127
  inWeight: 0.33333334
128
128
  outWeight: 0.33333334
129
129
  - serializedVersion: 3
130
- time: 0.85714287
131
- value: 100
130
+ time: 0.71428573
131
+ value: 80
132
132
  inSlope: 0
133
133
  outSlope: 0
134
134
  tangentMode: 136
@@ -136,8 +136,8 @@ AnimationClip:
136
136
  inWeight: 0.33333334
137
137
  outWeight: 0.33333334
138
138
  - serializedVersion: 3
139
- time: 1.4285715
140
- value: -110
139
+ time: 1.2857143
140
+ value: -80
141
141
  inSlope: 0
142
142
  outSlope: 0
143
143
  tangentMode: 136
@@ -24,9 +24,9 @@ RectTransform:
24
24
  m_PrefabInstance: {fileID: 0}
25
25
  m_PrefabAsset: {fileID: 0}
26
26
  m_GameObject: {fileID: 812134488303599474}
27
- m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
27
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
28
28
  m_LocalPosition: {x: 0, y: 0, z: 0}
29
- m_LocalScale: {x: 1.1, y: 1.1, z: 1.1}
29
+ m_LocalScale: {x: 0.9, y: 0.9, z: 0.9}
30
30
  m_ConstrainProportionsScale: 1
31
31
  m_Children:
32
32
  - {fileID: 312166748021578777}
@@ -35,7 +35,7 @@ RectTransform:
35
35
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
36
36
  m_AnchorMin: {x: 0.5, y: 0.5}
37
37
  m_AnchorMax: {x: 0.5, y: 0.5}
38
- m_AnchoredPosition: {x: 0, y: 220}
38
+ m_AnchoredPosition: {x: 0, y: 210}
39
39
  m_SizeDelta: {x: 279.2293, y: 106.4023}
40
40
  m_Pivot: {x: 0.5, y: 0.5}
41
41
  --- !u!222 &277624337904105659
@@ -138,6 +138,7 @@ MonoBehaviour:
138
138
  startCtaLabel: {fileID: 3096530613615201642}
139
139
  blinkingText: {fileID: 791952873962332395}
140
140
  swipeGif: {fileID: 3581598360722608337}
141
+ handSpriteInGif: {fileID: 312166748021578777}
141
142
  --- !u!1 &5738334876670918407
142
143
  GameObject:
143
144
  m_ObjectHideFlags: 0
@@ -248,7 +249,7 @@ RectTransform:
248
249
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
249
250
  m_AnchorMin: {x: 0.5, y: 0.5}
250
251
  m_AnchorMax: {x: 0.5, y: 0.5}
251
- m_AnchoredPosition: {x: -103, y: -40}
252
+ m_AnchoredPosition: {x: -90, y: -40}
252
253
  m_SizeDelta: {x: 84.6344, y: 106.4023}
253
254
  m_Pivot: {x: 0.5, y: 0.5}
254
255
  --- !u!222 &7348338096052556359
@@ -325,7 +326,7 @@ PrefabInstance:
325
326
  objectReference: {fileID: 0}
326
327
  - target: {fileID: 596696483668891729, guid: bc5495c08b5534447938b4459527fa86, type: 3}
327
328
  propertyPath: m_fontSize
328
- value: 130
329
+ value: 120.8
329
330
  objectReference: {fileID: 0}
330
331
  - target: {fileID: 596696483668891729, guid: bc5495c08b5534447938b4459527fa86, type: 3}
331
332
  propertyPath: m_margin.x
@@ -145,4 +145,30 @@ namespace Hyper.Shared
145
145
  /// </summary>
146
146
  SwipeToPlayHorizontal
147
147
  }
148
+
149
+ /// <summary>
150
+ /// Direction of swipe used for Start CTA visuals and gesture.
151
+ /// </summary>
152
+ public enum SwipeDirection
153
+ {
154
+ /// <summary>
155
+ /// Swipe upwards.
156
+ /// </summary>
157
+ Up,
158
+
159
+ /// <summary>
160
+ /// Swipe downwards.
161
+ /// </summary>
162
+ Down,
163
+
164
+ /// <summary>
165
+ /// Swipe to the left.
166
+ /// </summary>
167
+ Left,
168
+
169
+ /// <summary>
170
+ /// Swipe to the right.
171
+ /// </summary>
172
+ Right
173
+ }
148
174
  }
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "name": "Hyper.Shared",
3
3
  "rootNamespace": "Hyper.Shared",
4
- "references": [],
4
+ "references": [
5
+ "GUID:6055be8ebefd69e48b49212b09b47b2f"
6
+ ],
5
7
  "includePlatforms": [],
6
8
  "excludePlatforms": [],
7
9
  "allowUnsafeCode": false,
@@ -30,7 +30,7 @@ namespace Hyper.Internal
30
30
  {
31
31
  #if UNITY_EDITOR
32
32
  return true;
33
- #elif DEVELOPMENT_BUILD
33
+ #elif HYPER_DEVELOPMENT_BUILD
34
34
  return true;
35
35
  #else
36
36
  return false;
@@ -45,7 +45,7 @@ namespace Hyper.Internal
45
45
  /// <summary>
46
46
  /// Standard log message with HyperSDK prefix.
47
47
  /// </summary>
48
- [Conditional("UNITY_EDITOR"), Conditional("DEVELOPMENT_BUILD")]
48
+ [Conditional("UNITY_EDITOR"), Conditional("HYPER_DEVELOPMENT_BUILD")]
49
49
  public static void Log(string message, UnityEngine.Object context = null)
50
50
  {
51
51
  if (!IsLoggingEnabled) return;
@@ -55,7 +55,7 @@ namespace Hyper.Internal
55
55
  /// <summary>
56
56
  /// Info log with automatic caller detection.
57
57
  /// </summary>
58
- [Conditional("UNITY_EDITOR"), Conditional("DEVELOPMENT_BUILD")]
58
+ [Conditional("UNITY_EDITOR"), Conditional("HYPER_DEVELOPMENT_BUILD")]
59
59
  public static void Info(string message, UnityEngine.Object context = null)
60
60
  {
61
61
  if (!IsLoggingEnabled) return;
@@ -66,7 +66,7 @@ namespace Hyper.Internal
66
66
  /// <summary>
67
67
  /// Success log (green) with automatic caller detection.
68
68
  /// </summary>
69
- [Conditional("UNITY_EDITOR"), Conditional("DEVELOPMENT_BUILD")]
69
+ [Conditional("UNITY_EDITOR"), Conditional("HYPER_DEVELOPMENT_BUILD")]
70
70
  public static void LogSuccess(string message, UnityEngine.Object context = null)
71
71
  {
72
72
  if (!IsLoggingEnabled) return;
@@ -77,7 +77,7 @@ namespace Hyper.Internal
77
77
  /// <summary>
78
78
  /// Action log (blue) with automatic caller detection.
79
79
  /// </summary>
80
- [Conditional("UNITY_EDITOR"), Conditional("DEVELOPMENT_BUILD")]
80
+ [Conditional("UNITY_EDITOR"), Conditional("HYPER_DEVELOPMENT_BUILD")]
81
81
  public static void Action(string message, UnityEngine.Object context = null)
82
82
  {
83
83
  if (!IsLoggingEnabled) return;
@@ -88,7 +88,7 @@ namespace Hyper.Internal
88
88
  /// <summary>
89
89
  /// Warning log (orange) with HyperSDK prefix.
90
90
  /// </summary>
91
- [Conditional("UNITY_EDITOR"), Conditional("DEVELOPMENT_BUILD")]
91
+ [Conditional("UNITY_EDITOR"), Conditional("HYPER_DEVELOPMENT_BUILD")]
92
92
  public static void LogWarning(string message, UnityEngine.Object context = null)
93
93
  {
94
94
  if (!IsLoggingEnabled) return;
@@ -114,12 +114,22 @@ namespace Hyper.Internal
114
114
  /// </summary>
115
115
  private static string FormatMessage(string color, string prefix, string message)
116
116
  {
117
+
118
+ #if UNITY_EDITOR
117
119
  if (string.IsNullOrEmpty(prefix))
118
120
  {
119
121
  return $"<color={color}>{message}</color>";
120
122
  }
121
-
123
+
122
124
  return $"<color={color}>[{prefix}]</color> {message}";
125
+ #else
126
+ if (string.IsNullOrEmpty(prefix))
127
+ {
128
+ return $"{message}";
129
+ }
130
+
131
+ return $"[{prefix}] {message}";
132
+ #endif
123
133
  }
124
134
 
125
135
  #endregion
@@ -0,0 +1,67 @@
1
+ using TMPro;
2
+
3
+ namespace Hyper.Internal
4
+ {
5
+ /// <summary>
6
+ /// Internal number formatting utilities with minimal GC allocations.
7
+ /// </summary>
8
+ public static class HyperNumberFormatter
9
+ {
10
+ /// <summary>
11
+ /// Formats an <see cref="int"/> with thousand separators into the provided buffer.
12
+ /// Returns the number of characters written.
13
+ /// </summary>
14
+ /// <remarks>
15
+ /// - No string allocations.
16
+ /// - Caller must ensure <paramref name="buffer"/> is large enough for the largest expected value.
17
+ /// </remarks>
18
+ internal static int FormatIntWithCommas(int value, char[] buffer)
19
+ {
20
+ long v = value;
21
+ bool neg = v < 0;
22
+ if (neg) v = -v;
23
+
24
+ int i = buffer.Length;
25
+ int group = 0;
26
+
27
+ do
28
+ {
29
+ if (group == 3)
30
+ {
31
+ buffer[--i] = ',';
32
+ group = 0;
33
+ }
34
+
35
+ buffer[--i] = (char)('0' + (v % 10));
36
+ v /= 10;
37
+ group++;
38
+ } while (v != 0);
39
+
40
+ if (neg)
41
+ {
42
+ buffer[--i] = '-';
43
+ }
44
+
45
+ int len = buffer.Length - i;
46
+
47
+ // Shift to the beginning of the buffer
48
+ for (int k = 0; k < len; k++)
49
+ {
50
+ buffer[k] = buffer[i + k];
51
+ }
52
+
53
+ return len;
54
+ }
55
+
56
+ /// <summary>
57
+ /// Convenience helper: formats <paramref name="value"/> into <paramref name="buffer"/>
58
+ /// and applies it to the given <see cref="TMP_Text"/> without allocations.
59
+ /// </summary>
60
+ public static void SetScoreNoAlloc(TMP_Text text, int value, char[] buffer)
61
+ {
62
+ int len = FormatIntWithCommas(value, buffer);
63
+ text.SetCharArray(buffer, 0, len);
64
+ }
65
+ }
66
+ }
67
+
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 759fa1992061f1d42b7eeef01700a5a7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "app.hypergames.hypersdk",
3
- "version": "1.4.22",
3
+ "version": "1.5.1",
4
4
  "displayName": "HyperSDK",
5
5
  "description": "Official Unity SDK for Hyper: multiplayer battles, leaderboards, deterministic RNG, session management, tutorials, and WebGL optimizations for production-ready games.",
6
6
  "unity": "6000.0",