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,50 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class DebugFadeToggle : MonoBehaviour
|
||||
{
|
||||
public Image targetImage;
|
||||
public float duration = 0.5f;
|
||||
|
||||
bool isVisible = true;
|
||||
Coroutine running;
|
||||
|
||||
void Start()
|
||||
{
|
||||
var btn = GetComponent<Button>();
|
||||
if (btn != null)
|
||||
btn.onClick.AddListener(ToggleFade);
|
||||
}
|
||||
|
||||
public void ToggleFade()
|
||||
{
|
||||
if (targetImage == null) return;
|
||||
|
||||
float targetAlpha = isVisible ? 0f : 1f;
|
||||
if (running != null) StopCoroutine(running);
|
||||
running = StartCoroutine(FadeTo(targetAlpha));
|
||||
isVisible = !isVisible;
|
||||
}
|
||||
|
||||
IEnumerator FadeTo(float targetAlpha)
|
||||
{
|
||||
float start = targetImage.color.a;
|
||||
float t = 0f;
|
||||
|
||||
while (t < duration)
|
||||
{
|
||||
t += Time.deltaTime;
|
||||
float a = Mathf.Lerp(start, targetAlpha, Mathf.Clamp01(t / duration));
|
||||
var c = targetImage.color;
|
||||
c.a = a;
|
||||
targetImage.color = c;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
var final = targetImage.color;
|
||||
final.a = targetAlpha;
|
||||
targetImage.color = final;
|
||||
running = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e99816cb33c22f840bae5c4d5be9523f
|
||||
@@ -0,0 +1,54 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ProceduralEditor
|
||||
{
|
||||
// Runtime helper that toggles the alpha of a target Image when the Button it's attached to is clicked.
|
||||
public class DebugFadeToggleBridge : MonoBehaviour
|
||||
{
|
||||
public Image targetImage;
|
||||
public float duration = 0.1f;
|
||||
|
||||
bool isVisible = true;
|
||||
Coroutine running;
|
||||
|
||||
void Start()
|
||||
{
|
||||
var btn = GetComponent<Button>();
|
||||
if (btn != null)
|
||||
btn.onClick.AddListener(ToggleFade);
|
||||
}
|
||||
|
||||
public void ToggleFade()
|
||||
{
|
||||
if (targetImage == null) return;
|
||||
|
||||
float targetAlpha = isVisible ? 0f : 1f;
|
||||
if (running != null) StopCoroutine(running);
|
||||
running = StartCoroutine(FadeTo(targetAlpha));
|
||||
isVisible = !isVisible;
|
||||
}
|
||||
|
||||
IEnumerator FadeTo(float targetAlpha)
|
||||
{
|
||||
float start = targetImage.color.a;
|
||||
float t = 0f;
|
||||
|
||||
while (t < duration)
|
||||
{
|
||||
t += Time.deltaTime;
|
||||
float a = Mathf.Lerp(start, targetAlpha, Mathf.Clamp01(t / duration));
|
||||
var c = targetImage.color;
|
||||
c.a = a;
|
||||
targetImage.color = c;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
var final = targetImage.color;
|
||||
final.a = targetAlpha;
|
||||
targetImage.color = final;
|
||||
running = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94f21b7480673b540bd619ed7bb266f9
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dcac9b4ec2e8fe143ac611df7f4b548f
|
||||
Reference in New Issue
Block a user