Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by danosono · Oct 04, 2020 at 12:48 PM · buttonsscrollingautomationlevel select

Could anyone offer suggestions on automating a 3 deep scrolling menu that chooses a level for gameplay?

Hi everyone :)

I am making a typing game; the levels are strings such as public string myString = @"the string to type"; and the player types the strings for a wpm ....

There are many short levels so I have a scrolling level selection menu with a hierarchy of 3 levels of scrolling buttons; the first (Header) scrolling menu leads to a new (subHeader) scrolling menu which, when a button is selected, leads to the 3rd (level selection) scrolling menu; the buttons on this 3rd level actually choose the level with something like chooseLevel(levelSelected); where levelSelected is the text of the last button clicked.

I am using a button script and a control script for each of the 3 scrolling menus.

I have 30 to 40 levels currently (under various Header/subHeaders but may add hundreds more.

When I add a level, I sometimes need to make changes to all 3 control scripts and the switch statement on the script choosing the level.

I want to automate all this as follows (or some better way). I would like to code it so the control scripts for each scrolling menu receive the button information from the level itself. So, public string MyString = @"the string to type"; would now look more like

 public string[] MyStringLevelOne = "header", "subHeader", "levelSelectionButtonText", @"the string to type";

Actually, more like,

 public string[] MyStringLevelOne = "People in the New Testament", "Paul", "Acts 9:1", @"the string to type";

The control scripts would choose their button from the array above. I am having a hard time getting my mind around how to code this though. Each control script would need to get its button info from the array. This way, I only need to add the levels and all the buttons are updated automatically. I suppose a for loop?

I will get to work on the for loop... please offer suggestions if you can steer me in a more direct path...

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 danosono · Oct 07, 2020 at 08:54 PM 0
Share

So I have been kicking this around and now I am thinking of making a list of multiple arrays. Each array (in the list) would contain 4 strings, 1) the header (top scrolling menu- button's text), 2) subHeader (second scrolling menu- button's text), 3) a level name (third level menu- button's text - always unique to allow the player to choose a unique level) and 4) the actual text used in the gameplay which is also always unique.

 public string[] sample {"People", "Jesus", "John 14:6", @"Jesus said to him, “I am the way, and the truth, and the life; no one comes to the Father but through $$anonymous$$e."};

 

The top scrolling menu control script would foreach through all the arrays' [0] index position and create a button for each unique entry. This would omit redundant header entries in the [0] position and only make one button per unique header. Top scrolling menu buttons= "People", "Things", etc

Once a button is selected, the second scrolling menu control script would compare (foreach) the pressed button's text with the all array's [0] index position and only take the ones that match (here, the matching redundant header entries are all and only included), then foreach again only through the now reduced list of arrays to make buttons from the [1] index position. Second scrolling menu buttons = "Paul", "Jesus"; "ground", "tree"; etc

Once a second scrolling menu button is pressed, the third scrolling menu control script would filter the arrays in the list only taking the arrays who's [1] index position matches the button that was just pressed and create the third scrolling menu with buttons from the matching array's [2] index position. Third scrolling menu buttons = "Acts 9:4", John 14:6" ; "John 18:6", "Gal 3:13"

Once a button is pressed on the third scrolling menu, the third scrolling menu control script will start the gameplay and set the gameplay text to equal the array's [3] position string.

Now all the menu control scripts are automated and , to add a new level, I only need to add an array[4] to the list and all the menus, buttons and gameplay texts will automatically generate at runtime.

The question is, do I use a list of many arrays or a list of many instances of a class (with the 4 strings defined) or a dictionary of classes or something else?

Thanks so much if you have read all this and I appreciate any suggestions and the opportunity to learn...

Thanks :)

Danny

avatar image danosono · Oct 10, 2020 at 09:31 PM 0
Share

Hi :)

I want to create multiple string arrays with 4 strings each and then foreach through them all.

     public string[] first = {"headerButtonText1", "subHeaderButtonText1", "levelButtoneText1", "textForGameplay1"} 
     
     public string[] second = {"headerButtonText2", "subHeaderButtonText2", "levelButtoneText2", "textForGameplay2"} 

So, I want to now place these in a list or something so I can foreach through them all to pull data from them.

Like:

public List levels = new List(); //somehow add all the string[] arrays to the list

levels.Add(public string[] first); levels.Add(public string[] second);

// even better, create the arrays in the list in the first place. then, foreach (level[] in levels) { // if (I have not already created a button == level[0]) { make a button with buttonText = level[0]} }

This would continue with level[1], level[2] , etc for the following menu of buttons.

Thanks for any direction.

avatar image danosono · Oct 19, 2020 at 12:10 AM 0
Share

Solved :)

I used a jagged array (string [][]) and then used Array.IndexOf(Array,string) to cycle through them.

Thanks for the tough love.

If anyone would like to see the code, I'll be happy to share it.

Now I can add one array to the jagged array and all three scrolling menus are automated with out the need for me to make any changes on the three scrolling menu's control scripts; they read from the array on another script. The new additions don't need to be in order and it doesn't matter if I am adding a completely new topic. Nice :)

0 Replies

· Add your reply
  • Sort: 

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

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

Related Questions

Optimal usage of resources - level numbers 0 Answers

my background is not scrolling why? 1 Answer

Scrollable world map with mouse drag or finger 0 Answers

Can someone explain GUIContent and GUIStyle? 0 Answers

how to make a main menu button 0 Answers


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