Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to make a database of items which are unlocked at certain levels?

Discussion in 'Scripting' started by will_brett, Dec 25, 2014.

  1. will_brett

    will_brett

    Joined:
    Feb 16, 2013
    Posts:
    208
    Hey all,

    First of all Merry Xmas!

    Im working on a project that currently has a very convoluted way of setting up and organising shop items. Each shop item is made up of the following:

    1. Item image (Sprite)
    2. Item Name (Label)
    3. Cost (Label)
    4. Script attached that tells the game what to do when the object is purchased
    Currently each item is custom made as a separate game object which is super slow and time consuming to adjust and balance. The GameObjects are then set to inactive at start and then activated if the player has unlocked them in game.

    What I would ideally like to be able to do is to create a database (Possibly scriptable object) that holds all this info and then instantiates the gameobjects into the shop when unlocked. I would like to be able to use a template shop item too if possible.

    Any ideas of how to go about doing this? Have you come across any tutorials that explain this type of thing? I would really love to learn as I can think of many different uses for this knowledge;.

    Thanks

    Will
     
  2. kietus

    kietus

    Joined:
    Jun 4, 2013
    Posts:
    54
    Hello,

    You can start with an xml file that will define the settings of yours objects. (eg wiki xmlSerialize ).
    And you can store objects or "parts" in the Resources folder. (Resources.Load)
     
  3. will_brett

    will_brett

    Joined:
    Feb 16, 2013
    Posts:
    208
    Thanks Kietus, I will take a look at this. Not used XML with unity before but sure it would be something worth learning :)
     
  4. will_brett

    will_brett

    Joined:
    Feb 16, 2013
    Posts:
    208
    It certainly looks interesting but not sure how to use this with a template shop item.

    I suppose I will need to try creating a data base of shop items that can be saved to xml and then figure out how to load them and then change the template accordingly.

    If anyone knows of any tutorials that would be a huge help.