Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Grasshorse · Jun 21, 2011 at 02:32 PM · texturearrayrepeatbutton

Passing Texture Names from Array to Buttons

Hello, I have been working on writing a script that will allow me to store all of the names of buttons in an array. With code like this.

var spellTextureArray:Array = new Array( spellTexture0, spellTexture1, spellTexture2, spellTexture3);

Then I try and do a for loop to iterate through the creation of the buttons like this.

 for(var j:int = 0; j < spellArray.length; j++)
 {
     if (spellArray[j].Contains(Event.current.mousePosition))
     {
         if (GUI.RepeatButton(Rect(spellArray[j]), spellTextureArray[j]) && mdown == false)
         {
             mdown = true;
             //print("spell " + j + " mouse is down");
         }
         else
         {
             mdown = false;
             //print("spell " + j + " mouse is up");
         }
     }
     else
     {
         GUI.RepeatButton(Rect(spellArray[j]), spellTextureArray[j]);
     }
 }

The textures names are not passing to the GUI.RepeatButton operation. I can hard code the name and the texture shows up, so I know the texture is linked. Is there something obvious that I am missing? This has me pretty stumped.

Best Regards,

Steve

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
1
Best Answer

Answer by Yanger_xy · Jun 21, 2011 at 03:06 PM

Check your spellTextureArray. Are you sure that its elements are validating?

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 Grasshorse · Jun 21, 2011 at 03:52 PM 0
Share

Thanks Yanger,

You're right, it's not accepting the values into the array. Of course if I change them to strings, it does, but then the buttons print the name of the texture as text, and not the desired result of linking the textures to the buttons.

So it looks like the root of the trouble is in the array code, and not the button code. Have any ideas of how to store a name of a texture in an array? Or to convert the string into a command in the button code?

Thanks for your help on this! $$anonymous$$uch appreciated.

Steve

avatar image Grasshorse · Jun 21, 2011 at 03:59 PM 0
Share

Sweet! I figured it out. After assigning the strings to the array, I reassigned them as the name and kapow! it worked. Thanks Yanger!

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

Null Reference Exception After refering to an Array 1 Answer

Array of buttons not displaying in game 1 Answer

Getting error: ArgumentException: Destination array is not long enough to copy all the items in the collection. Check array index and length. 2 Answers

Link image sequence to an array 2 Answers

Array based floor 3D game flat plane 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