scene 1 login ,scen...
 
Notifications
Clear all

scene 1 login ,scene 2 inventory

7 Posts
2 Users
0 Reactions
628 Views
(@megaman)
Posts: 34
Trusted Member
Topic starter
 

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.

 
Posted : 09/07/2014 11:39 am
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

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

 
Posted : 09/07/2014 11:49 am
(@megaman)
Posts: 34
Trusted Member
Topic starter
 

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

 
Posted : 09/07/2014 12:50 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

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

 
Posted : 09/07/2014 12:59 pm
(@megaman)
Posts: 34
Trusted Member
Topic starter
 

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

 
Posted : 09/07/2014 1:06 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

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

 
Posted : 09/07/2014 1:23 pm
(@megaman)
Posts: 34
Trusted Member
Topic starter
 

Works!! just restarted unity and it works! thank you for your help!! ;))

 
Posted : 09/07/2014 1:42 pm
Share: