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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by mmangual_83 · Jan 04, 2014 at 05:45 PM · c#listrandom

Printing an ordered list

I have been working on this program for a WHILE now and I got it working for the most part. What my program does is randomly picks an element from a list of strings. I have been told by @HappyMoo (who has been a BIG help so far) to create another list to store the order in which the strings are selected. But what I need help with is how to print out what order according to the random string generator.

This diagram should help:

alt text

I also tried using extension classes to output the random strings but all that does is just print the list together and not separately how I want it.

Also, what @ArkaneX said also made it clear to me what I had to do which was use ToArray() to output the list. The problem is that it only outputs the list in the default order.

 string[] gestureOptions = {
                                   Cube_DemoPhase.task1Gesture[0],
                                   Cube_DemoPhase.task1Gesture[1],
                                   Cube_DemoPhase.task1Gesture[2]
                               };


Next, I managed to create the following but this does not work as it only outputs the list in the default order as well.

 for (int i = gestureOptions.Length - 1; i > 0; i--)
         {
 
             gestureOptions[i] = Cube_DemoPhase.index[i].ToString();
         }


What I wanted to do here is output the string list based in the order that the random number generator has chosen.

Can anyone help me figure out what I need to do to get to work how I want it? Thank you again!

randomoutput.png (23.9 kB)
Comment
Add comment · Show 4
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 Kumo-Kairo · Jan 04, 2014 at 06:36 PM 0
Share

Can you show the code of your random number generator? It seems that you can just make a list and consecutively add randomly generated items to it, so the order will persist through this process

avatar image mmangual_83 · Jan 04, 2014 at 07:37 PM 0
Share

I have. I have an extra list that stores the random int, what I need to know is how do I get it to work in the for loop I created

avatar image iwaldrop · Jan 04, 2014 at 08:00 PM 0
Share

As an example of over-complication, why do you initialize an array to the values of another array individually like that? It is a very hard-coded solution that assumes the length of the source array never changes. Better to use System.Array.Copy ins$$anonymous$$d so that you can safely change the source's length without worry.

avatar image ArkaneX · Jan 05, 2014 at 10:35 PM 0
Share

Please see my updated answer to OP's other question...

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Mikea15 · Jan 10, 2014 at 02:11 PM

You can use .net's SortedList Collection.

More info after the jump => http://www.dotnetperls.com/sortedlist

Just add them and set the ordering to be the Random Number generator. You will probably have to check if you can add the same ordering number twice tho. And I don't know if this is supported by Mono.

Cheers.

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

21 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

Related Questions

A node in a childnode? 1 Answer

Making a camera list 1 Answer

my random task generator not working 1 Answer

Printing a GUI selection grid in order 1 Answer

Multiple Cars not working 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