1. Enter the Microsoft Developer Challenge for a chance to win prizes. Read more about it here.
  2. Enter the Google Play Indie Games Contest in Europe. Read more about it here.
  3. Unity 5.5 is now released.
  4. Become a closed-alpha partner on the new Facebook games platform. Read more about it here.
  5. Get early access to our Google Daydream Technical preview. Click here for more details!

Unity Tutorials Inventory

Discussion in 'Scripting' started by Black-Mantis, May 12, 2010.

  1. Black-Mantis


    Feb 7, 2010
    Hello all i recently purchased the inventory tutorial from the unity tutorials. and when i got it the vid was screwed up, so after asking them several times to just give a small explanation for the set up of the scripts. They insist i wait months for the new vid. So no disrespect to those guys they were very nice.(But i dont have months to wait and wanted to ask any one here that also purchased the tutorial to give a small description of where to put the scripts and how to set them up? :D Ofc it would'nt be cool for me to post the code since those guys are still selling this product :D
  2. kfrench16


    Mar 22, 2009
    I bought that vid as well.

    You need to put your scripts on an empty Game object. Just like everything else in Unity, Game Objects drive the system.

    And you can follow along with the videos without their commentary.
  3. Black-Mantis


    Feb 7, 2010
    TY For the reply, I wish i could follow along with the vid, Half of it is just black screen and that i can see the audio is a few minutes off. i tried some of my video editing programs to alter the sound track but no real step in the right direction.

    I cant complain to much though, they gave me a refund, but as i mentioned to them a couple of times (via)email that they could just keep the money if they just take five minutes to explain how to set the scripts up. Its probably easy i just allready tried to tinker with it and was :? so i put it aside.
    Plus im not a blackbelt at code chi yet :D
  4. tonyd


    Jun 2, 2009
    I haven't seen the video you are referring to, but how complex an inventory system do you need?

    You can do a simple inventory using nothing more than an Array or ArrayList.

    Code (csharp):
    1. static var inventory = new ArrayList();
    Save that to a javascript named Master. You do NOT need to attach this to anything else.

    You call it from other scripts using Master.inventory, and can add/remove/display it like so:

    Code (csharp):
    1. function Start(){
    2.     Master.inventory.Add("pistol"); //add item to inventory
    3.     Master.inventory.AddRange(Array("key", "key", "ammo", "ammo")); //add multiple items
    4.     Master.inventory.Sort(); //sort inventory
    5.     Master.inventory.Remove("ammo"); //remove first instance of item
    6. }
    8. function OnGUI(){
    9.     GUI.Label(Rect(0,0,400,50), "Inventory: " + Array(Master.inventory)); //display inventory by converting it to an array
    10. }
  5. runningbird


    Sep 3, 2009
    The video needs to be viewed in Quick Time.

    When I watched it in Media Player the sound was off and other issues.

    I don't have the video anymore HD died and I can't contact them to get a new link etc...

    Good tutorial though.