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 Whelandrew · Aug 26, 2014 at 10:47 PM · textmeshwordwrap

Instantiate and create a list of objects evenly

I instantiate a set of objects with TextMeshes and I run a WordWrap function. So I have a series of text objects of varying heights. Assuming that I have the height value for each text mesh what would be my method of sorting this objects beneath each other at an even distance?

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

Answer by LSPressWorks · Aug 26, 2014 at 11:39 PM

heightValue + space

So if box one is at 35 px y+

          35px    12px         2px

Box2.y = (box1.y + box1.height + space);

OR by using a for statement with the array length, it's no parenthesis in unity btw...

            35px         12px       2px

box[i].y = (box[i-1].y + box[i-1].height + space);

Where the second method is preferred since it can handle a wider range of input, literally any number of elements inside the array.

is your coordinate method center or 0x,0x based? if it is center based, you probably have to multiple the space by number of elements in your initial array or vector. now if you're asking how to sort them like, alphabetically you need to load their values into an array, pop(bubble) sort the values, then apply those values.

Comment
Add comment · Show 3 · 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 LSPressWorks · Aug 26, 2014 at 11:42 PM 0
Share

ps, use a 2 or 3 dimensional array. Easier to track coordiantes I$$anonymous$$HO

avatar image Whelandrew · Aug 27, 2014 at 08:13 PM 0
Share

Thanks! I was having one of those moments where I needed someone else to explain what I already knew. :p

avatar image tpainton · Apr 28, 2015 at 08:01 PM 0
Share

The above code will generate index out of range.

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

TextMesh wordwrap 4 Answers

TextMeshPro to wordwrap on every character 1 Answer

Word Wrap forces font to revert to default settings 2 Answers

How to access planes generated by TextMesh? 1 Answer

Text Mesh + GuiTexture2D 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