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 superventure · Jan 24, 2014 at 11:43 PM · arraylistresize

Can you set a string length when declaring it to a certain other number?

Need to set a texture[] variable to be the length of a game object[] variable. How do I do that? I thought I could just use lists and resize it in start ie

 var items : List.<GameObject>;
 var icons : List.<Texture>;
 
 icons.Count = items.Count; // need something like this in Start function

this works to set the length, but I'm using it for a gui selection grid and get a console error at this line

 lineupInt = GUI.SelectionGrid (Rect (0 , 0, boxwidth, boxheight), lineupInt, icons, 3);

the setup I have is to make a selection grid representing the player's inventory items icons.

Please DO NOT suggest arrays. I'm trying to get off using them. Thanks

Comment
Add comment · Show 3
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 oatsbarley · Jan 25, 2014 at 12:13 AM 0
Share

What error do you get on that line?

avatar image superventure · Jan 25, 2014 at 12:17 AM 0
Share
 CE0023: No appropriate version of 'UnityEngine.GUI.SelectionGrid' for the argument list '(UnityEngine.Rect, int, UnityEngine.texture[], int)' was found.
avatar image Jamora · Jan 25, 2014 at 09:51 AM 0
Share

Trying to not use arrays in program$$anonymous$$g is akin to trying not to see an advertisment downtown. Arrays are everywhere, often hidden... List uses an array internally.

$$anonymous$$aybe you mean you were using an array before and now want to use something else. In this case, List is a good choice.

2 Replies

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

Answer by superventure · Jan 25, 2014 at 05:02 AM

System.Array.Resize. (icons, items.Length);

Link to check out

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 Fabkins · Jan 25, 2014 at 01:21 AM

i think you are trying to use the selection grid with these arguments:

 static function SelectionGrid(position: Rect, selected: int, images: Texture[], xCount: int): int;

My guess is that argument 3 is the problem. Its supposed to be an array of Textures and you've made it a list of no particular type. Whether you want to use arrays or not, that method requires an array of textures and thats what you are going to have to give it.

(im assuming lineupInt is indeed an int)

Comment
Add comment · Show 1 · 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 superventure · Jan 25, 2014 at 01:32 AM 0
Share

Darn. I was trying to bypass having to set the texture[] length in the inspector to be the length of another specific string automatically. Do you know if you can set it that way when declaring it? Something like var icons : Texture[] = obs.length?

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

23 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Javascript Endless 3D Array 0 Answers

A node in a childnode? 1 Answer

Make the audio manager select from an array of sounds 1 Answer

List all children in array? 5 Answers

Preventing Items from shifting in a list 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