app.hypergames.hypersdk 1.2.2 → 1.3.0
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/CHANGELOG.md +7 -0
- package/Editor/Scripts/Utils/HyperSceneReferenceDrawer.cs +37 -0
- package/HyperLoader.unity +1 -1
- package/Runtime/Internal/Bootstrap/HyperLoader.cs +5 -0
- package/Runtime/Internal/Core/HyperRuntime.cs +40 -0
- package/Runtime/Internal/UI/Modals/GameOverModal.cs +2 -22
- package/Runtime/Internal/UI/Modals/GamePausedModal.cs +1 -17
- package/Runtime/Public/Core/HyperSDK.cs +19 -0
- package/Runtime/Resources/UIPrefabs/GameOverModal_Battle.prefab +1 -1
- package/Runtime/Resources/UIPrefabs/GameOverModal_Practice.prefab +1 -1
- package/Runtime/Resources/UIPrefabs/GamePausedModal_Battle.prefab +1 -1
- package/Runtime/Resources/UIPrefabs/Scores Frame.prefab +5 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.3.0](https://github.com/mvmhyper/hyper-sdk/compare/v1.2.2...v1.3.0) (2025-11-26)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Soft restart lifecycle management and build index automation ([4426307](https://github.com/mvmhyper/hyper-sdk/commit/44263076306a4d0ec1b84a053123f34a164450de))
|
|
7
|
+
|
|
1
8
|
## [1.2.2](https://github.com/mvmhyper/hyper-sdk/compare/v1.2.1...v1.2.2) (2025-11-26)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
using UnityEditor;
|
|
3
3
|
using UnityEngine;
|
|
4
4
|
using Hyper.Shared;
|
|
5
|
+
using Hyper.Internal;
|
|
5
6
|
|
|
6
7
|
namespace Hyper.Editor
|
|
7
8
|
{
|
|
@@ -58,6 +59,9 @@ namespace Hyper.Editor
|
|
|
58
59
|
guidProperty.stringValue = newGUID;
|
|
59
60
|
pathProperty.stringValue = newPath;
|
|
60
61
|
nameProperty.stringValue = newName;
|
|
62
|
+
|
|
63
|
+
// Automatically add scene to build index if not already present
|
|
64
|
+
EnsureSceneInBuildIndex(newPath, newName);
|
|
61
65
|
}
|
|
62
66
|
else
|
|
63
67
|
{
|
|
@@ -69,6 +73,39 @@ namespace Hyper.Editor
|
|
|
69
73
|
|
|
70
74
|
EditorGUI.EndProperty();
|
|
71
75
|
}
|
|
76
|
+
|
|
77
|
+
/// <summary>
|
|
78
|
+
/// Ensures the scene is added to the build index if it's not already present.
|
|
79
|
+
/// </summary>
|
|
80
|
+
private void EnsureSceneInBuildIndex(string scenePath, string sceneName)
|
|
81
|
+
{
|
|
82
|
+
if (string.IsNullOrEmpty(scenePath))
|
|
83
|
+
return;
|
|
84
|
+
|
|
85
|
+
// Check if scene is already in build index
|
|
86
|
+
var buildScenes = EditorBuildSettings.scenes;
|
|
87
|
+
bool isInBuildIndex = false;
|
|
88
|
+
|
|
89
|
+
for (int i = 0; i < buildScenes.Length; i++)
|
|
90
|
+
{
|
|
91
|
+
if (buildScenes[i].path == scenePath)
|
|
92
|
+
{
|
|
93
|
+
isInBuildIndex = true;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Add to build index if not present
|
|
99
|
+
if (!isInBuildIndex)
|
|
100
|
+
{
|
|
101
|
+
var newScenes = new EditorBuildSettingsScene[buildScenes.Length + 1];
|
|
102
|
+
System.Array.Copy(buildScenes, newScenes, buildScenes.Length);
|
|
103
|
+
newScenes[buildScenes.Length] = new EditorBuildSettingsScene(scenePath, true);
|
|
104
|
+
EditorBuildSettings.scenes = newScenes;
|
|
105
|
+
|
|
106
|
+
HyperDebug.LogSuccess($"Automatically added scene '{sceneName}' to Build Settings.");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
72
109
|
}
|
|
73
110
|
}
|
|
74
111
|
#endif
|
package/HyperLoader.unity
CHANGED
|
@@ -305,7 +305,7 @@ RectTransform:
|
|
|
305
305
|
m_AnchorMin: {x: 0, y: 1}
|
|
306
306
|
m_AnchorMax: {x: 0, y: 1}
|
|
307
307
|
m_AnchoredPosition: {x: 489.20746, y: -280.1698}
|
|
308
|
-
m_SizeDelta: {x:
|
|
308
|
+
m_SizeDelta: {x: 0, y: 239.347}
|
|
309
309
|
m_Pivot: {x: 0.5, y: 0.5}
|
|
310
310
|
--- !u!114 &751153944
|
|
311
311
|
MonoBehaviour:
|
|
@@ -46,6 +46,11 @@ namespace Hyper.Internal
|
|
|
46
46
|
|
|
47
47
|
private void Awake()
|
|
48
48
|
{
|
|
49
|
+
// Entering a freshly loaded HyperLoader scene always ends any previous
|
|
50
|
+
// soft-restart window. From this point onward, teardown code should treat
|
|
51
|
+
// object destruction as part of a normal lifecycle again.
|
|
52
|
+
HyperRuntime.IsSoftRestarting = false;
|
|
53
|
+
|
|
49
54
|
HyperRuntime.Clear();
|
|
50
55
|
|
|
51
56
|
InitializeComponents();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
using System;
|
|
2
2
|
using UnityEngine;
|
|
3
|
+
using UnityEngine.SceneManagement;
|
|
3
4
|
using Hyper.Internal.Managers;
|
|
4
5
|
|
|
5
6
|
namespace Hyper.Internal
|
|
@@ -15,6 +16,7 @@ namespace Hyper.Internal
|
|
|
15
16
|
private static GameObject _singletonObject;
|
|
16
17
|
|
|
17
18
|
private static bool _isInitialized;
|
|
19
|
+
private static bool _isSoftRestarting;
|
|
18
20
|
private static HyperSDKSettings _settings;
|
|
19
21
|
private static HyperGameContentConfig _gameContent;
|
|
20
22
|
private static GameManager _gameManager;
|
|
@@ -24,6 +26,11 @@ namespace Hyper.Internal
|
|
|
24
26
|
private static TimerManager _timerManager;
|
|
25
27
|
|
|
26
28
|
internal static bool IsInitialized => _isInitialized;
|
|
29
|
+
internal static bool IsSoftRestarting
|
|
30
|
+
{
|
|
31
|
+
get => _isSoftRestarting;
|
|
32
|
+
set => _isSoftRestarting = value;
|
|
33
|
+
}
|
|
27
34
|
internal static HyperSDKSettings Settings => _settings;
|
|
28
35
|
internal static HyperGameContentConfig GameContent => _gameContent;
|
|
29
36
|
internal static GameManager GameManager => _gameManager;
|
|
@@ -32,6 +39,20 @@ namespace Hyper.Internal
|
|
|
32
39
|
internal static EventManager EventManager => _eventManager;
|
|
33
40
|
internal static TimerManager Timer => _timerManager;
|
|
34
41
|
|
|
42
|
+
/// <summary>
|
|
43
|
+
/// Perform a full soft restart of the Hyper session.
|
|
44
|
+
///
|
|
45
|
+
/// This is the internal implementation used by both the public
|
|
46
|
+
/// HyperSDK facade and internal UI flows (pause/game over modals).
|
|
47
|
+
/// </summary>
|
|
48
|
+
internal static void RestartSession()
|
|
49
|
+
{
|
|
50
|
+
_isSoftRestarting = true;
|
|
51
|
+
|
|
52
|
+
ClearAllDontDestroyOnLoadObjects();
|
|
53
|
+
SceneManager.LoadScene("HyperLoader");
|
|
54
|
+
}
|
|
55
|
+
|
|
35
56
|
internal static void Initialize(Action callback)
|
|
36
57
|
{
|
|
37
58
|
ValidatePlatform();
|
|
@@ -141,10 +162,28 @@ namespace Hyper.Internal
|
|
|
141
162
|
|
|
142
163
|
_host = null;
|
|
143
164
|
_isInitialized = false;
|
|
165
|
+
_isSoftRestarting = false;
|
|
144
166
|
|
|
145
167
|
HyperDebug.Log("Cleared and reset");
|
|
146
168
|
}
|
|
147
169
|
|
|
170
|
+
/// <summary>
|
|
171
|
+
/// Clears all root objects residing in the DontDestroyOnLoad scene.
|
|
172
|
+
/// Intended to be used as part of a controlled soft restart flow.
|
|
173
|
+
/// </summary>
|
|
174
|
+
private static void ClearAllDontDestroyOnLoadObjects()
|
|
175
|
+
{
|
|
176
|
+
var allObjects = Resources.FindObjectsOfTypeAll<GameObject>();
|
|
177
|
+
|
|
178
|
+
foreach (var obj in allObjects)
|
|
179
|
+
{
|
|
180
|
+
if (obj.scene.name == "DontDestroyOnLoad" && obj.transform.parent == null)
|
|
181
|
+
{
|
|
182
|
+
UnityEngine.Object.Destroy(obj);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
148
187
|
internal static void OnHostDestroyed(HyperRuntimeHost host)
|
|
149
188
|
{
|
|
150
189
|
if (_host != host) return;
|
|
@@ -163,6 +202,7 @@ namespace Hyper.Internal
|
|
|
163
202
|
_dataManager = null;
|
|
164
203
|
_gameContent = null;
|
|
165
204
|
_isInitialized = false;
|
|
205
|
+
_isSoftRestarting = false;
|
|
166
206
|
}
|
|
167
207
|
}
|
|
168
208
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
using System.Collections;
|
|
2
2
|
using TMPro;
|
|
3
3
|
using UnityEngine;
|
|
4
|
-
using UnityEngine.SceneManagement;
|
|
5
4
|
using UnityEngine.UI;
|
|
6
5
|
using System.Runtime.InteropServices;
|
|
7
6
|
using Hyper.Internal.Managers;
|
|
@@ -86,7 +85,7 @@ namespace Hyper.Internal
|
|
|
86
85
|
|
|
87
86
|
while (elapsedTime < duration)
|
|
88
87
|
{
|
|
89
|
-
elapsedTime += Time.
|
|
88
|
+
elapsedTime += Time.unscaledDeltaTime;
|
|
90
89
|
loadingBarSlider.value = Mathf.Lerp(startValue, targetValue, elapsedTime / duration);
|
|
91
90
|
yield return null;
|
|
92
91
|
}
|
|
@@ -168,26 +167,7 @@ namespace Hyper.Internal
|
|
|
168
167
|
|
|
169
168
|
public void PlayAgain()
|
|
170
169
|
{
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
private void FullGameRestart()
|
|
175
|
-
{
|
|
176
|
-
ClearAllDDOLObjects();
|
|
177
|
-
SceneManager.LoadScene("HyperLoader");
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
private void ClearAllDDOLObjects()
|
|
181
|
-
{
|
|
182
|
-
GameObject[] allObjects = Resources.FindObjectsOfTypeAll<GameObject>();
|
|
183
|
-
|
|
184
|
-
foreach (GameObject obj in allObjects)
|
|
185
|
-
{
|
|
186
|
-
if (obj.scene.name == "DontDestroyOnLoad" && obj.transform.parent == null)
|
|
187
|
-
{
|
|
188
|
-
Destroy(obj);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
170
|
+
HyperRuntime.RestartSession();
|
|
191
171
|
}
|
|
192
172
|
|
|
193
173
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
using TMPro;
|
|
2
2
|
using UnityEngine;
|
|
3
|
-
using UnityEngine.SceneManagement;
|
|
4
3
|
using UnityEngine.UI;
|
|
5
4
|
using System.Runtime.InteropServices;
|
|
6
5
|
using Hyper.Internal.Managers;
|
|
@@ -136,22 +135,7 @@ namespace Hyper.Internal
|
|
|
136
135
|
|
|
137
136
|
public void RestartGame()
|
|
138
137
|
{
|
|
139
|
-
|
|
140
|
-
SceneManager.LoadScene("HyperLoader");
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
private void ClearAllDDOLObjects()
|
|
144
|
-
{
|
|
145
|
-
GameObject[] allObjects = Resources.FindObjectsOfTypeAll<GameObject>();
|
|
146
|
-
|
|
147
|
-
foreach (GameObject obj in allObjects)
|
|
148
|
-
{
|
|
149
|
-
if (obj.scene.name == "DontDestroyOnLoad" && obj.transform.parent == null)
|
|
150
|
-
{
|
|
151
|
-
Debug.Log($"Destroying DDOL object: {obj.name}");
|
|
152
|
-
Destroy(obj);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
138
|
+
HyperRuntime.RestartSession();
|
|
155
139
|
}
|
|
156
140
|
}
|
|
157
141
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
using System;
|
|
2
2
|
using UnityEngine;
|
|
3
|
+
using UnityEngine.SceneManagement;
|
|
3
4
|
using Hyper.Internal;
|
|
4
5
|
using Hyper.Internal.Managers;
|
|
5
6
|
|
|
@@ -20,6 +21,23 @@ namespace Hyper
|
|
|
20
21
|
/// </summary>
|
|
21
22
|
public static bool IsInitialized => HyperRuntime.IsInitialized;
|
|
22
23
|
|
|
24
|
+
/// <summary>
|
|
25
|
+
/// Indicates that Hyper is currently performing a soft restart.
|
|
26
|
+
///
|
|
27
|
+
/// This is only true during the teardown/transition between sessions
|
|
28
|
+
/// when DontDestroyOnLoad objects are being cleared and the HyperLoader
|
|
29
|
+
/// scene is being (re)loaded. Once the new loader starts, this flag is reset.
|
|
30
|
+
///
|
|
31
|
+
/// Intended usage:
|
|
32
|
+
/// - Distinguish soft restart vs real quit in teardown logic
|
|
33
|
+
/// (e.g. singleton OnDestroy guards) to avoid false positives.
|
|
34
|
+
/// </summary>
|
|
35
|
+
public static bool IsSoftRestarting
|
|
36
|
+
{
|
|
37
|
+
get => HyperRuntime.IsSoftRestarting;
|
|
38
|
+
internal set => HyperRuntime.IsSoftRestarting = value;
|
|
39
|
+
}
|
|
40
|
+
|
|
23
41
|
/// <summary>
|
|
24
42
|
/// Initialize the Hyper SDK. Must be called before accessing other APIs.
|
|
25
43
|
/// </summary>
|
|
@@ -95,6 +113,7 @@ namespace Hyper
|
|
|
95
113
|
|
|
96
114
|
_eventAdapter.RefreshBindings();
|
|
97
115
|
}
|
|
116
|
+
|
|
98
117
|
}
|
|
99
118
|
|
|
100
119
|
/// <summary>
|
|
@@ -462,7 +462,7 @@ RectTransform:
|
|
|
462
462
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
|
463
463
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
|
464
464
|
m_AnchoredPosition: {x: 0, y: 0}
|
|
465
|
-
m_SizeDelta: {x:
|
|
465
|
+
m_SizeDelta: {x: 3, y: 113.3299}
|
|
466
466
|
m_Pivot: {x: 0.5, y: 0.5}
|
|
467
467
|
--- !u!222 &3311437449879540859
|
|
468
468
|
CanvasRenderer:
|
|
@@ -36,7 +36,7 @@ RectTransform:
|
|
|
36
36
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
|
37
37
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
|
38
38
|
m_AnchoredPosition: {x: 0, y: 0}
|
|
39
|
-
m_SizeDelta: {x:
|
|
39
|
+
m_SizeDelta: {x: 3, y: 113.3299}
|
|
40
40
|
m_Pivot: {x: 0.5, y: 0.5}
|
|
41
41
|
--- !u!222 &6183820688932751126
|
|
42
42
|
CanvasRenderer:
|
|
@@ -603,7 +603,7 @@ RectTransform:
|
|
|
603
603
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
|
604
604
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
|
605
605
|
m_AnchoredPosition: {x: 0, y: 0}
|
|
606
|
-
m_SizeDelta: {x:
|
|
606
|
+
m_SizeDelta: {x: 3, y: 113.3299}
|
|
607
607
|
m_Pivot: {x: 0.5, y: 0.5}
|
|
608
608
|
--- !u!222 &7271924545119143605
|
|
609
609
|
CanvasRenderer:
|
|
@@ -36,7 +36,7 @@ RectTransform:
|
|
|
36
36
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
|
37
37
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
|
38
38
|
m_AnchoredPosition: {x: 0, y: 0}
|
|
39
|
-
m_SizeDelta: {x:
|
|
39
|
+
m_SizeDelta: {x: 3, y: 113.3299}
|
|
40
40
|
m_Pivot: {x: 0.5, y: 0.5}
|
|
41
41
|
--- !u!222 &533477767077768701
|
|
42
42
|
CanvasRenderer:
|
|
@@ -270,7 +270,7 @@ MonoBehaviour:
|
|
|
270
270
|
m_text: FINAL SCORE
|
|
271
271
|
m_isRightToLeft: 0
|
|
272
272
|
m_fontAsset: {fileID: 11400000, guid: b61cc31493416594290d3793968a7776, type: 2}
|
|
273
|
-
m_sharedMaterial: {fileID:
|
|
273
|
+
m_sharedMaterial: {fileID: -6106472849309118677, guid: b61cc31493416594290d3793968a7776, type: 2}
|
|
274
274
|
m_fontSharedMaterials: []
|
|
275
275
|
m_fontMaterial: {fileID: 0}
|
|
276
276
|
m_fontMaterials: []
|
|
@@ -408,7 +408,7 @@ MonoBehaviour:
|
|
|
408
408
|
m_text: LAST SUBMITTED
|
|
409
409
|
m_isRightToLeft: 0
|
|
410
410
|
m_fontAsset: {fileID: 11400000, guid: b61cc31493416594290d3793968a7776, type: 2}
|
|
411
|
-
m_sharedMaterial: {fileID:
|
|
411
|
+
m_sharedMaterial: {fileID: -6106472849309118677, guid: b61cc31493416594290d3793968a7776, type: 2}
|
|
412
412
|
m_fontSharedMaterials: []
|
|
413
413
|
m_fontMaterial: {fileID: 0}
|
|
414
414
|
m_fontMaterials: []
|
|
@@ -556,7 +556,7 @@ MonoBehaviour:
|
|
|
556
556
|
m_text: 10,200
|
|
557
557
|
m_isRightToLeft: 0
|
|
558
558
|
m_fontAsset: {fileID: 11400000, guid: 39c484b4a22288c488625a88b6da2145, type: 2}
|
|
559
|
-
m_sharedMaterial: {fileID:
|
|
559
|
+
m_sharedMaterial: {fileID: -8342687123090027242, guid: 39c484b4a22288c488625a88b6da2145, type: 2}
|
|
560
560
|
m_fontSharedMaterials: []
|
|
561
561
|
m_fontMaterial: {fileID: 0}
|
|
562
562
|
m_fontMaterials: []
|
|
@@ -692,7 +692,7 @@ MonoBehaviour:
|
|
|
692
692
|
m_text: 10,000
|
|
693
693
|
m_isRightToLeft: 0
|
|
694
694
|
m_fontAsset: {fileID: 11400000, guid: 39c484b4a22288c488625a88b6da2145, type: 2}
|
|
695
|
-
m_sharedMaterial: {fileID:
|
|
695
|
+
m_sharedMaterial: {fileID: -8342687123090027242, guid: 39c484b4a22288c488625a88b6da2145, type: 2}
|
|
696
696
|
m_fontSharedMaterials: []
|
|
697
697
|
m_fontMaterial: {fileID: 0}
|
|
698
698
|
m_fontMaterials: []
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "app.hypergames.hypersdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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",
|