I want to develop a simple 2d online game in unity, the problem is moving information between scenes, for example, im currently playing on server X(scene 1 in unity) and I have gained y XP, then how should I show the XP on the main menu(scene 0)? maybe at the end of the round, should I update the database and then retrieve data from the database in the main menu? sorry for my ignorance, i never developed any online game.
imagine you have a function: void GameIsfinished() inside you can put your save stuff,then when save is done you can load the menu scene. saving data is not related to networking if you use unity network or photon for example. you can save using playerprefs ( only local save), using database or using a cloud server it depend greatly of the game you are doing. a simple solution: save your value in player prefs when you enter a scene you have a PlayerData script that you observe for changes. so when you finish loading your saved values, all other player will receive your changes.
You could also have a conatiner object with all the information you need, which won't be destroyed when switching scenes. Just make a gameobject with the information about the player, and then add this script to the playerObject: Code (CSharp): using UnityEngine; using System.Collections; public class DontDestroy : MonoBehaviour { void Start () { DontDestroyOnLoad(gameObject); } } (You don't have to make a new "DontDestory.cs" script if you just need it once, then just add the command "DontDestroyOnLoad(gameObject);" to any startMethod of your container object. Saving will be important as well, but not necessary for your current task.