Add main menu scene with Rive UI, procedural background, and scene transitions
- Add Menu scene with Rive-driven login and navigation UI (RiveLoginController, RiveNavigationController) for entering a username and starting/navigating the client via Rive triggers - Add SceneTransitionController to fade out and load the Landscape gameplay scene when Play is selected - Add procedural low-poly triangle field background and animated wave panel (LowPolyTriangleField, TriangleWavePanel) with matching editor menus and materials - Add MenuLightAnimator for animated menu lighting and UI fade helpers (MenuFadeIn, DebugFadeToggle/Bridge) - Rename SampleScene to Landscape and wire ChatNetworkManager to hide the new Rive login canvas once gameplay starts - Bump Input System action codegen version and add Rive package references/project settings updates to support the new UI
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(CanvasGroup))]
|
||||
public class MenuFadeIn : MonoBehaviour
|
||||
{
|
||||
public float delay = 0.3f;
|
||||
public float duration = 3.5f;
|
||||
|
||||
CanvasGroup _group;
|
||||
Coroutine _fadeRoutine;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
// Ensure a CanvasGroup exists (SetupMainMenuScene adds one, but be defensive)
|
||||
_group = GetComponent<CanvasGroup>();
|
||||
if (_group == null) _group = gameObject.AddComponent<CanvasGroup>();
|
||||
|
||||
_group.alpha = 1f;
|
||||
_group.blocksRaycasts = true;
|
||||
Debug.Log("[MenuFadeIn] Awake - CanvasGroup ensured, alpha=1");
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
// Reset state whenever enabled and start the fade
|
||||
if (_group == null) _group = GetComponent<CanvasGroup>() ?? gameObject.AddComponent<CanvasGroup>();
|
||||
_group.alpha = 1f;
|
||||
_group.blocksRaycasts = true;
|
||||
|
||||
if (_fadeRoutine != null) StopCoroutine(_fadeRoutine);
|
||||
_fadeRoutine = StartCoroutine(Fade());
|
||||
Debug.Log("[MenuFadeIn] OnEnable - starting fade (delay=" + delay + ", duration=" + duration + ")");
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
if (_fadeRoutine != null)
|
||||
{
|
||||
StopCoroutine(_fadeRoutine);
|
||||
_fadeRoutine = null;
|
||||
Debug.Log("[MenuFadeIn] OnDisable - stopped fade coroutine");
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator Fade()
|
||||
{
|
||||
if (delay > 0f) yield return new WaitForSecondsRealtime(delay);
|
||||
|
||||
float t = 0f;
|
||||
while (t < duration)
|
||||
{
|
||||
t += Time.unscaledDeltaTime;
|
||||
_group.alpha = 1f - Mathf.Clamp01(t / duration);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
_group.alpha = 0f;
|
||||
_group.blocksRaycasts = false;
|
||||
Debug.Log("[MenuFadeIn] Fade finished - disabling GameObject");
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user