diff --git a/Assets/1.TeamWorkspace/MainMenu/Scene/Module Select.unity b/Assets/1.TeamWorkspace/MainMenu/Scene/Module Select.unity
index 4604bc9..30b4194 100644
--- a/Assets/1.TeamWorkspace/MainMenu/Scene/Module Select.unity
+++ b/Assets/1.TeamWorkspace/MainMenu/Scene/Module Select.unity
@@ -365,7 +365,7 @@ MonoBehaviour:
- {fileID: 2800000, guid: 9d4aec44cae8848019e0e5b106b69e7b, type: 3}
- {fileID: 2800000, guid: 072659c261670478192bba1df123a40f, type: 3}
distance: 2
- canvasScale: 0.0015
+ canvasScale: 0.0013
recentreAngle: 40
recentreSpeed: 2.5
inputGrace: 0.6
diff --git a/Assets/1.TeamWorkspace/MainMenu/Scripts/ModuleSelectMenu.cs b/Assets/1.TeamWorkspace/MainMenu/Scripts/ModuleSelectMenu.cs
index 851eb53..bca1b4f 100644
--- a/Assets/1.TeamWorkspace/MainMenu/Scripts/ModuleSelectMenu.cs
+++ b/Assets/1.TeamWorkspace/MainMenu/Scripts/ModuleSelectMenu.cs
@@ -32,7 +32,7 @@ public class ModuleSelectMenu : MonoBehaviour
[Tooltip("Metres in front of the player.")]
public float distance = 2.0f;
[Tooltip("World metres per canvas unit. The layout below is authored in millimetres.")]
- public float canvasScale = 0.0015f;
+ public float canvasScale = 0.0013f;
[Tooltip("Degrees the player may turn away before the menu drifts back in front of them.")]
public float recentreAngle = 40f;
public float recentreSpeed = 2.5f;
@@ -92,6 +92,7 @@ class Entry
bool launching, placed;
float fade;
Vector3 targetPos;
+ float placedEyeY;
string pendingScene;
// ------------------------------------------------------------------ lifecycle
@@ -109,6 +110,8 @@ void Awake()
BuildCanvas();
BuildFader();
SelectFirstAvailable();
+ // Hidden until it has been put in front of a tracked head; see Place.
+ root.gameObject.SetActive(false);
}
void Update()
@@ -116,6 +119,7 @@ void Update()
if (!ResolveCamera()) return;
input.Update();
Place();
+ if (!placed) return;
if (launching)
{
@@ -232,23 +236,33 @@ void Launch(Entry e)
///
/// World-locked, not head-locked: a panel welded to the eyes is unpleasant to read and would
/// make gaze selection impossible. It only drifts back once the player has turned well away.
+ ///
+ /// On a headset the first frames come before the first tracked head pose: the camera still sits
+ /// at the rig origin, which on a floor-level rig is the floor. Placing the menu then put it in
+ /// the ground with only its top edge showing. So it waits for a tracked head, and it snaps
+ /// again whenever the head height jumps (tracking starting late, a recentre, sitting down).
///
void Place()
{
+ if (!placed && !HeadReady()) return;
+
Vector3 forward = Flatten(cam.forward);
Vector3 wanted = cam.position + forward * distance;
wanted.y = cam.position.y - 0.12f;
- if (!placed)
+ if (!placed || Mathf.Abs(cam.position.y - placedEyeY) > HeightJump)
{
targetPos = wanted;
root.position = wanted;
root.rotation = Quaternion.LookRotation(Flatten(wanted - cam.position), Vector3.up);
+ placedEyeY = cam.position.y;
+ if (!placed) root.gameObject.SetActive(true);
placed = true;
}
else if (Vector3.Angle(forward, Flatten(targetPos - cam.position)) > recentreAngle)
{
targetPos = wanted;
+ placedEyeY = cam.position.y;
}
float t = 1f - Mathf.Exp(-recentreSpeed * Time.unscaledDeltaTime);
@@ -261,6 +275,24 @@ void Place()
faderRoot.rotation = cam.rotation;
}
+ const float HeightJump = 0.3f;
+
+ ///
+ /// True once the headset reports a tracked head, or straight away when there is no headset
+ /// (editor, desktop test) and the camera never gets a pose at all.
+ ///
+ bool HeadReady()
+ {
+ var head = UnityEngine.XR.InputDevices.GetDeviceAtXRNode(UnityEngine.XR.XRNode.Head);
+ float age = Time.unscaledTime - born;
+ if (!head.isValid) return age > 0.25f;
+ // Never wait forever: if tracking is never reported, show it anyway (the height-jump snap
+ // still corrects it once a real pose arrives).
+ if (age > 3f) return true;
+ return head.TryGetFeatureValue(UnityEngine.XR.CommonUsages.isTracked, out bool tracked) && tracked
+ && cam.localPosition.sqrMagnitude > 0.0001f;
+ }
+
static Vector3 Flatten(Vector3 v)
{
v.y = 0f;
@@ -664,7 +696,7 @@ public static class ModuleSelectText
public const string TutorialTitle = "Module 2 - Tutorial";
public const string GamaTitle = "GAMA / IP setup";
- public const string Hint = "Look at a module, then press A stick to move | hold B in game to come back here";
+ public const string Hint = "Look at a module, then press A | in a module, press MENU twice to come back here";
public const string HintDesktop = "Arrows to move, Space to start desktop test mode - no headset detected";
public const string NotInBuild = "Scene missing from the build list (File > Build Profiles)";
}
diff --git a/Assets/1.TeamWorkspace/MainMenu/Scripts/ReturnToMenu.cs b/Assets/1.TeamWorkspace/MainMenu/Scripts/ReturnToMenu.cs
index dc510dd..ae043b8 100644
--- a/Assets/1.TeamWorkspace/MainMenu/Scripts/ReturnToMenu.cs
+++ b/Assets/1.TeamWorkspace/MainMenu/Scripts/ReturnToMenu.cs
@@ -1,24 +1,28 @@
using TMPro;
using UnityEngine;
+using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
///
-/// "Hold B to leave" - the way out of a module and back to .
+/// The way out of a module and back to , in two forms:
+/// - press the left controller's MENU button twice (the second within ).
+/// That is the button a Quest player already reaches for to "go to the menu". Twice, because
+/// one stray press must not throw away a child's progress; the first press says what the
+/// second will do;
+/// - hold B / Y for . B is used because the modules only ever tap it
+/// (Module 1's "press anything to fly again", Module 3's "no"); none of them holds it.
+/// No module on main reads the menu button.
///
/// It installs itself into every scene through and
/// survives scene loads, so neither module scene nor any module script has to be touched to gain
-/// it. That is deliberate: Module_1_MainScene.unity is ~38k lines of YAML and every edit to
-/// it is a merge conflict waiting for whoever is working on the other branch.
-///
-/// The hold is long enough () that nobody leaves a module by fumbling a
-/// button, and a progress bar appears while holding so it is discoverable rather than a secret.
-/// B / Y is used because the modules only ever tap it (Module 1's "press anything to fly again",
-/// Module 3's "no"); none of them holds it.
+/// it. That is deliberate: the module scenes are tens of thousands of lines of YAML and every edit
+/// to one is a merge conflict waiting for whoever is working on the other branch.
///
public class ReturnToMenu : MonoBehaviour
{
public const float HoldSeconds = 1.5f;
+ public const float ArmSeconds = 3f;
const float ShowAfterSeconds = 0.3f;
static ReturnToMenu instance;
@@ -27,9 +31,10 @@ public class ReturnToMenu : MonoBehaviour
Transform cam;
RectTransform root;
CanvasGroup group;
- Image fill;
+ Image track, fill;
TextMeshProUGUI label;
bool leaving;
+ float armedUntil;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
static void Install()
@@ -44,13 +49,16 @@ void Awake()
{
BuildIndicator();
SceneManager.sceneLoaded += OnSceneLoaded;
+ // Installed after the first scene has loaded, so its sceneLoaded has already gone by.
+ OnSceneLoaded(SceneManager.GetActiveScene(), LoadSceneMode.Single);
}
- // This object outlives every scene, so the "already leaving" latch has to be cleared on each
- // load; otherwise only the first trip back to the menu per app launch would work.
+ // This object outlives every scene, so per-scene state is reset on each load; in particular
+ // the "already leaving" latch, or only the first trip back per app launch would work.
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
leaving = false;
+ armedUntil = 0f;
}
void Update()
@@ -69,25 +77,40 @@ void Update()
}
input.Update();
- float held = Mathf.Clamp01(input.SecondaryHeld / HoldSeconds);
+ float now = Time.unscaledTime;
+
+ if (input.MenuDown)
+ {
+ if (now < armedUntil) { Leave(); return; }
+ armedUntil = now + ArmSeconds;
+ input.Rumble();
+ }
+ if (input.SecondaryHeld >= HoldSeconds) { Leave(); return; }
// A quick tap of B is an answer in Module 3 ("no"), so the bar only shows once the press is
// clearly a hold, rather than flashing up on every tap.
- bool show = input.SecondaryHeld > ShowAfterSeconds;
- group.alpha = Mathf.MoveTowards(group.alpha, show ? 1f : 0f, Time.unscaledDeltaTime * 8f);
- fill.fillAmount = held;
- label.text = ReturnToMenuText.Holding;
+ string text = null;
+ bool bar = false;
+ if (input.SecondaryHeld > ShowAfterSeconds) { text = ReturnToMenuText.Holding; bar = true; }
+ else if (now < armedUntil) text = ReturnToMenuText.PressAgain;
+
+ group.alpha = Mathf.MoveTowards(group.alpha, text != null ? 1f : 0f, Time.unscaledDeltaTime * 6f);
+ if (text != null) label.text = text;
+ track.enabled = fill.enabled = bar;
+ fill.fillAmount = Mathf.Clamp01(input.SecondaryHeld / HoldSeconds);
+ // Text in the middle on its own; above the bar when there is one.
+ label.rectTransform.offsetMin = new Vector2(20f, bar ? 44f : 10f);
// Sits below the line of sight so it never covers what the player is doing.
- root.position = cam.position + cam.rotation * new Vector3(0f, -0.26f, 0.9f);
+ root.position = cam.position + cam.rotation * new Vector3(0f, -0.32f, 0.9f);
root.rotation = cam.rotation;
+ }
- if (input.SecondaryHeld >= HoldSeconds)
- {
- leaving = true;
- input.Rumble(0.6f, 0.15f);
- AppFlow.ReturnToMenu();
- }
+ void Leave()
+ {
+ leaving = true;
+ input.Rumble(0.6f, 0.15f);
+ AppFlow.ReturnToMenu();
}
void OnDestroy()
@@ -101,34 +124,37 @@ void BuildIndicator()
int layer = LayerMask.NameToLayer("UI");
if (layer < 0) layer = 5;
- var go = new GameObject("Hold Indicator") { layer = layer };
+ var go = new GameObject("Return Indicator") { layer = layer };
go.transform.SetParent(transform, false);
var canvas = go.AddComponent