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 BlitzSam · Aug 30, 2014 at 03:42 PM · arraynewbie

GUI only showing texture of the newest addition in the array. Help?

Hi all. 1st off, thanks to everyone that has helped me out a huge lot over the last few days. You guys really made my 1st steps into coding a lot more bearable than otherwise :)

Ok, problem time:

function OnGUI()

{ for (var g : GameObject in InventoryGrid) { items= g.GetComponent(ItemIdentifier).ItemTexture; } GUI.skin = MenuSkin; if (DisplayCharacter)

{ GUI.BeginGroup (new Rect(Screen.width*0.3,Screen.height*0.1,Screen.width*0.4,Screen.height*0.8));

GUI.Box(Rect(0,0,Screen.width*0.4,Screen.height*0.8),"");

 for(i=0;i<InventoryGrid.length;i++)
 {
 GUI.Button(Rect(0+(i*Screen.width*0.05),0,Screen.height*0.05, Screen.height*0.05),items);
 }

GUI.EndGroup (); }

^ So, basically I'm made an array to display the Icons (ItemTexture) found within an Item Script (ItemIdentifier) of Objects from my array (Inventory Grid)

alt text

^In the 1st photo, my inventory is empty. In the next one, I've added 5 maces. In the third, I added a new item with a blank texture and all the previous 5 textures were cleared. However, when i added another mace, now all the textures are maces again.

untitled.png (95.2 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by everett24 · Aug 30, 2014 at 07:51 PM

My best guess is that you should set your Items texture in the same spot you use it, ex

  if(show inventory)
     for(var i : int = 0; i < number of items in inventory; i++)
     {
     texture to use = item texture;
     GUI.Button(Rect(0+(i*Screen.width*0.05),0,Screen.height*0.05, Screen.height*0.05), texture to use);
     }

I think whats happening is that your item texture is being set to the last item in your inventory -Everett

Comment
Add comment · Show 2 · 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 BlitzSam · Aug 31, 2014 at 08:57 PM 0
Share

Thanks for the suggestion. I actually spent a wholesomely long time to fix the issue, it required quite some recoding. $$anonymous$$aybe I'll try your method some time later on, looks quite a bit more efficient. Cheers anyways :)

avatar image everett24 · Sep 01, 2014 at 01:21 AM 0
Share

good to hear you fixed it

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Deleting an Element from an Array. 1 Answer

How to make sound play once until called again 1 Answer

Sphere detection system 2 Answers

Using an array instead 2 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