Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs-unity.molca.id/llms.txt

Use this file to discover all available pages before exploring further.

Folder: Assets/_MolcaSDK/Code/Scripts/Auth/
Namespace: MolcaSDK.Auth
TypeRole
AuthUIFlat / guest login UI wired to AuthManager (RuntimeManager subsystem) — not the VR ScenarioSessionManager flow unless you bridge separately
UserData / SDKUserDataGuest display name payloads (GuestLogin)

Code

Inspector-driven: AuthUI assigns TMP_InputField, error texts, SharedString nextSceneName, and guest panel buttons. On start it await RuntimeManager.WaitForInitialization(), registers AuthEvents.LoggedIn, and loads nextSceneName.value after a successful login. Programmatic login (same as OnLoginClicked):
using Molca;
using Molca.Networking.Auth;
using UnityEngine;

public class CustomLogin : MonoBehaviour
{
    public async void Login(string user, string pass)
    {
        await RuntimeManager.WaitForInitialization();
        var auth = RuntimeManager.GetSubsystem<AuthManager>();
        if (auth == null) return;

        bool ok = await auth.LoginAsync(user, pass);
        Debug.Log(ok ? "OK" : "Failed");
    }
}
Guest path (matches OnGuestClicked — confirmation modal then GuestLogin):
using Molca;
using Molca.Networking.Auth;
using Molca.Modals;

public static void GuestAs(string displayName)
{
    RuntimeManager.GetSubsystem<AuthManager>()
        .GuestLogin(new SDKUserData("Guest", displayName));
}
VR OTP / member flows stay on ScenarioSessionManager — see Session authentication.

Troubleshooting

  • Scene does not load after loginAuthEvents.LoggedIn must fire; SharedString nextSceneName must match a registered scene. Check SceneLoadManager / build settings.
  • Login always fails — Verify AuthManager subsystem, backend URL/auth config in your project, and that LoginAsync errors surface (UI sets a generic invalid-credentials message on usernameErrorText only for the main path).
  • Guest panel stuckguestPanel Show/Hide is manual from buttons; ensure guestLoginCancelButton clears the panel.
  • Start raceAuthUI awaits WaitForInitialization; do not call LoginAsync from Awake on the same object before that completes.

Unity Editor

Auth Ui Inspector