Hello, my question , if i may, is how to best setup an inventory scene after user logged?
if load scene from scene i logged there is CBManager.instance.isAuthenticated = False and i cant CBManager.instance.loggedUser.LoadInventory(); as well.
Thanks.
Ideally you have the CBManager component attached to a GameObject that is persistent during the game/app lifetime, for example I personally ever have an object GameManager with a script that handles generic stuff (prefabs, hierarchy object for other managers, etc) and has DontDestroyOnLoad(gameObject) in the Start() function so I just add the CBManager prefab under this object in the hierarchy. This way everything works smooth and the authenticated user is persistent for the lifetime.
FRANCESCO CROCETTI @ SKARED CREATIONS
thanks its CBManager.instance.isAuthenticated = true now. working
now i am stuck at last part on displaying the info:
so as a inventory i am using copy of DemoShop.cs script and add
CBUser user;
then at Start ()
user = CBManager.instance.loggedUser;
player = user as MyUser;
Debug.Log("CBManager.instance.loggedUser = " + CBManager.instance.loggedUser);
shows: correct user info, items etc
Debug.Log("player = " + player);
shows: player = MyUser
but OnGUI displays no CBManager.instance.loggedUser's values
Do you mean that OnGUI doesn't display the user's inventory? Did you call LoadInventory? If you look at OnUserLogin and OnUserUpdate events in the DemoShop script, it's called after login and user update, but in your case you should skip the event OnUserLogin (since you're managing the login on a previous scene) and call it directly in the Start function:
player = (MyUser)CBManager.instance.loggedUser; player.LoadInventory();
FRANCESCO CROCETTI @ SKARED CREATIONS
this is my start() looks alike
void Start () {
player = CBManager.instance.loggedUser as MyUser;
inventoryItems = new CBInventory[0];
purchaseItem = null;
player.LoadInventory();
}
in result says No items in your inventory but log says there are items
Mmh.. I'm not having this issue, I'm sending to you the two scenes and test scripts that I'm using for the test.
FRANCESCO CROCETTI @ SKARED CREATIONS
Works!! just restarted unity and it works! thank you for your help!! ;))