I’m making a register/login system in unity.I’ve managed to do it and the user can register and log in normally and start the next scene.
The problem is in the next scene the user doesn’t have his status(username etc…).
How can I do to acces to this information on the other scene ? Thank you.
You could make data container class for your session and player data and store them in to a Toolbox. I’ve written a simple ToolBox example here that details with GameManager how you can make cross-scene MonoBehaviors and non-behaviors with SaveSystem.
Alternatively you can check out more complex version of a Toolbox from Unity Wiki.
Toolbox is basically a singleton for storing references, so it persist between scenes. The Gameobjects attached to Behaviors that are stored in toolbox should call GameObject.DontDestroyOnLoad to avoid getting destroyed during scene transition.
static is pretty simple, just use it correctly. Just remember static is shared, so you wouldn’t want for example static enemy health as all enemies using the same code would share the same health. I would suggest you research singletons and static before you start using it as there is some things to keep in mind about them.
this:
public string username;
becomes this:
public static string username;
Then you access username with
DataBaseManager.username