Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Theacesofspades · Feb 18, 2013 at 05:10 AM · javascriptarraysinventoryclasses

Inventory Help.

So i am making an inventory (well attempting), and i need some help on what to do next. I have an inventory box that pops up that is made of buttons, then i have an array that i can add things to, but where do i go from here? Here are my scripts:

Inventory Script:

 var Inventory = new Array ();
 
 var emptySlot : Texture;
 var showInventory = false;
 
 var ex1 : float = 2.8;
 var why1 : float = 5.8;
 var exBig : float = 200;
 var whyBig : float = 200;
 
 var ex2 : float = 2.8;
 var why2 : float = 5.8;
 
 
 
 function Update () 
 {
     Debug.Log(Inventory.length);
 }
 
 function OnGUI ()
 {
     if (GUI.Button(Rect(Screen.width-100, Screen.height/2-50, 100, 100), emptySlot))
     {
         if (!showInventory)
         {
             showInventory = true;
         }else{
             showInventory = false;
         }
     }
     
     if (showInventory)
     {
         GUI.Box(Rect(Screen.width/ex1, Screen.height/why1, exBig, whyBig), "Inventory");
         
         for (var x=1; x<6; x++)
         {
             for (var y=1; y<6; y++)
             {
                 if (GUI.Button(Rect(Screen.width/ex2+x*50, Screen.height/why2+y*50, 50, 50), emptySlot))
                 {
                     
                 }
             }
         }
     }
 }

Add Item Script:

 var inventoryObject : Transform;
 
 
 function Item ()
 {
     var name : String;
     var description : String;
     var myIcon : Texture;
 }
 
 
 
 function Update () 
 {
     if (Input.GetKeyDown("e"))
     {
         inventoryObject.GetComponent(Inventory).Inventory.Add(Item);
     }
 }

Where do i go from here? And can you tell me if im going in the right direction. Thanks!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Bincredible · Feb 19, 2013 at 10:45 PM

I am not too experienced with Inventory's but to me that looks like a good start! :) and from there. It depends on what you want to do with it next.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by MileSplit · Mar 05, 2013 at 10:59 PM

Hey i made a (noobish) inventory and this tutorial helped A TON

http://www.youtube.com/watch?v=QlF6t5gI5es

i think its tutorals 31-34

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Does anyone know of good tutorials for learning arrays and classes? 1 Answer

Why does it give me this error and how can i fix it? 1 Answer

I need help on Classes and Arrays for inventory. 1 Answer

I'm trying to add items to an inventory. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges