1

I need to shuffle a char array and have a string array that contains words "play" and "game" and have some buttons in my game like this: image1

and this is my code:

for (int i = 0; i < Answers.Length; i++) {
                BtnsCharacter = Answers [i].ToCharArray ();
            } 

but I need is to make a mess in my buttons arraignment wile converting to char in random in every level. like the image bellow for example:

image2

How could I do that

1

2 Answers 2

1
for (int i = 0; i < Answers.Length; i++) {

 char[] BtnsCharacter = Answers [i].ToCharArray ();

 char[] shuffled = BtnsCharacter.OrderBy(n => Guid.NewGuid()).ToArray();
} 
Sign up to request clarification or add additional context in comments.

2 Comments

Please explain your answer. Posting only code (especially without comments) helps no one to understand what is happening within the answer.
Thanks for your answer Symon but system shows me this error: F:\make app\p_amirza\p_amirza\Assets\Scripts\GameManager.cs(37,37): Error CS1061: 'System.Array' does not contain a definition for 'OrderBy' and no extension method 'OrderBy' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?) (CS1061) (Assembly-CSharp)
0

The answer not from Symon. From Me.

Anyway you have to reference the LINQ Namespace

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.