#Additive Scenes work only as host+client
12 messages · Page 1 of 1 (latest)
This is a bit convoluted...Your login UI should be in your offline scene and us a Network Authenticator. If login succeeds, client proceeds to Online scene, and can load additive scenes to that.
okay i will but rn i need to know why i can't change scene
when im in host+client everything works
So I made some changes and now in my offline scene I have to log in and then after clicking login if there is such an account in the database I send the information to authentication and then I would like to enter the game however here I continue to do something wrong and I don't know if it is the fault of the manager or authentication. The problem is that the client turns on but I think it is not ready and the scene does not change to the online scene.
Here is what i changed in loginpanel.cs:
`if (userData.Length == 3)
{
var auth = FindObjectOfType<CustomAuthenticator>();
auth.validUsername = userData[1];
auth.validPassword = userData[2];
myNetworkManagerScript.StartClient();
}`
Here is my Authenticator:
`using Mirror;
using UnityEngine;
public class CustomAuthenticator : NetworkAuthenticator
{
[Header("Server Config")]
public string validUsername;
public string validPassword;
public override void OnStartServer()
{
// Register handlers for authentication requests
NetworkServer.RegisterHandler<AuthRequestMessage>(OnAuthRequestMessage, false);
}
public override void OnStartClient()
{
// Register handler for authentication response
NetworkClient.RegisterHandler<AuthResponseMessage>(OnAuthResponseMessage, false);
}
public void OnAuthRequestMessage(NetworkConnectionToClient conn, AuthRequestMessage msg)
{
// Check credentials from client
if (msg.username == validUsername && msg.password == validPassword)
{
Debug.Log("Client authenticated successfully.");
// Inform client of success
conn.Send(new AuthResponseMessage { success = true });
ServerAccept(conn);
}
else
{
Debug.LogError("Client authentication failed.");
// Inform client of failure
conn.Send(new AuthResponseMessage { success = false });
ServerReject(conn);
}
}
public void OnAuthResponseMessage(AuthResponseMessage msg)
{
if (msg.success)
{
Debug.Log("Successfully authenticated on server.");
ClientAccept();
}
else
{
Debug.LogError("Authentication Response: Invalid Credentials");
ClientReject();
}
}
public struct AuthRequestMessage : NetworkMessage
{
public string username;
public string password;
}
public struct AuthResponseMessage : NetworkMessage
{
public bool success;
}
}`
And here is my networkmanager is inspired as in additivescenes in examples:
@dawn elm please i need your help