- Home /
Connection between menu and scene
I'm for a couple of months trying to figure out how i can take information from menu scene and gameplay scene and vice versa, for example:
I can customize my hero in the menu scene, give him a weapon or a hat for exemple.
But i want to have this information on gameplay scene
i could make a gameobject that dont destroy on load but im making it multiplayer, so i cant
i tried database too but it takes a lot of time to take information from database and to much code, so its certainly the worst way to do that, and it would be so anoying
Someone can help?
Answer by IvovdMarel · Jun 29, 2014 at 12:33 AM
Storing information just so it persists between scenes does not require a database. Storing information online and sharing it with others does require at least a simple form of a database.
What you're asking is two things.
1) Storing information on the client side. You can store information in PlayerPrefs, so it will persist even when the app stops and restarts. 2) Creating a multiplayer game. This is a lot more difficult. Make sure that you are ready for a task like this. If so, consider what exactly you need from your online system, check out database systems (NoSQL vs MySQL), serialising data as JSON objects etc.
Also, for multiplayer games (depending on what platform you'd like to build) check out GameCenter, Google Play and (if not iOS / Android) Photon Multiplayer solutions.
I can make multiplayer games just fine.. i know how to use rpcs and etc, i'm using photon network, my question is just about the information between scenes, and i think i will look into player prefs, thanks :D
Answer by Juice-Tin · Jun 29, 2014 at 01:17 AM
Just want to add, you can simply use static variables.
public class SaveData{ public static String hat; }
You can now say: SaveData.hat = "TopHat";
or
Debug.Log(SaveData.hat);
anywhere. The variable will persist between scenes and objects as long as the game is running.
Your answer
Follow this Question
Related Questions
MLAPI: Is it possible to obtain all connected client ids in the NetworkManager? 1 Answer
Security issues with Multi-player User Database? 2 Answers
Inventory with a Database 0 Answers
can firebase real-time database be used on a pc standalone game? 0 Answers
Storing data on a server to be used for player currency in a multiplayer game 1 Answer