Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Hedonsoft · Jun 28, 2012 at 03:08 PM · guitexture2dinventoryicon

Populate inventory with item icons

Hello everyone. I have my inventory window setup the way I want, but right now it only displays the number of the slot. I've been using a mish mash of tutorials that explain how to populate the inventory with random items from chests etc but I have a set number of items I need to place in the inventory. How can I get the item icons to show up in the slots?

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 
 public class MyGUI : MonoBehaviour {
     public GUISkin mySkin;
 
     public  float lootWindowHeight;
     
     public float buttonWidth = 40;
     public float buttonHeight = 40;
     private float _offset = 10;
     
     /********************************************************/
     /* Inventory Window Variables*/
     /********************************************************/
     private bool _displayInventory = true;
     private const int INVENTORY_WINDOW_ID = 1;
     private Rect _inventoryWindowRect= new Rect(10,10,170,265);
     private int _inventoryRows = 6;
     private int _inventoryCols = 4;
     private const string ARMY_MEN_PATH = "Item Icons/Army Men"; 
     // Use this for initialization
     
     void Start () {
         
     }
     
     // Update is called once per frame
     void Update () {
     
     }
     
     void OnGUI(){
         _inventoryWindowRect = GUI.Window(INVENTORY_WINDOW_ID, _inventoryWindowRect,InventoryWindow, "Inventory");
     }
 
     public void InventoryWindow(int id){
         int cnt = 0;
         for(int y = 0;y < _inventoryRows;y++){
             for(int x = 0;x < _inventoryCols;x++){
                 GUI.Button(new Rect(5 + (x * buttonWidth),20 + (y * buttonHeight),buttonWidth, buttonHeight),(x + y * _inventoryCols).ToString());
                 GUI.Button(new Rect(5 + (x * buttonWidth),20 + (y * buttonHeight),buttonWidth, buttonHeight),(x + y * _inventoryCols).ToString(),"box");    
                 cnt++;
             }
         }
         GUI.DragWindow();    
     }
     
     public void ToggleInventory(){
         
     }
 
 }
Comment
Add comment · Show 1
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 Artifactx · Jan 17, 2015 at 05:55 PM 0
Share

Hey, here is a tutorial, that show you how to create an inventory with the most common operations. https://www.youtube.com/watch?v=$$anonymous$$LaGkc87dDQ it also explains you how to populate the inventory with icons

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Epsilon Naught · Nov 13, 2012 at 01:03 AM

http://www.burgzergarcade.com/tutorials/game-engines/unity3d/132-unity3d-tutorial-item-icons

Hopefully helps!

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

6 People are following this question.

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

Related Questions

Inventory SlotID vs. RectPosition 0 Answers

GUI error with texture. 1 Answer

Screen.width and Screen.height does not cover screen. Why? 4 Answers

Inventory Help 0 Answers

How to select a texture in an inventory? 0 Answers


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