Search Unity

  1. We would like to hear your feedback about Unity and our products. Click here for more information.
    Dismiss Notice

Which one is the better way?

Discussion in 'Scripting' started by grka, Jan 14, 2015.

  1. grka


    Jan 14, 2015
    I'm writing a game where the player can walk through a village. When he clicks on an item then a new canvas element shows up which contains some buttons. When I click on the button, I want a new window open and presenting him a list of items that he could pick up.

    I see 2 possible ways to create this new window:
    1. I create a new canvas element in my current scene which displays the list of items
    2. I create a complete new scene which displays this item list.

    My question is now: what is the better solution? No 1 seems easier for me because I can keep all my game objects from the scene but then I have a smaller screen for displaying everything
    No 2 seems a bit difficult because I have no idea how to restore all my game objects and player position when the user returns to the game scene. On the other hand I would have a whole new scene where I have more freedom in the space with the things I want to be listed there
  2. yoash


    Sep 3, 2013
    Yes, the second option would involve you saving the information from the previous scene, like the location your player was standing when he opened the inventory. Here is some information of saving the scene.

    Depending on the complexity of your game, you can use PlayerPrefs to save information not only between scenes but also between game sessions. I think you will need to use PlayerPrefs+ though to save the Vector 3 (location) of your player. The easiest option for you is probably to simply open the inventory on your screen while the game is still being played.
  3. Baste


    Jan 24, 2013
    Putting the item list in a different scene seems like a very roundabout way of doing this. You'd also have to make one scene for every container in your game. That'll be a lot of scenes.

    You should go for 1. Or, even better, keep the canvas showing the buttons, and replace the elements in it.
    Kiwasi likes this.