• Register now to get access to thousands of Tutorials, Leaked content, Hot NSFW and much more. Join us as we build and grow the community.

Advertise Here

Advertise Here

Advertise Here

Creating Level Menu

Serpico

Asynchronous Code Expert
S Rep
0
0
0
Rep
0
S Vouches
0
0
0
Vouches
0
Posts
51
Likes
140
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 100 XP
Operating System

Android

First create a new scene by pressing ctrl + n then save it in the scene directory as "Level Menu".

Set the component value of the canvas as shown below.
Level Menu UI

Next create a image and new canvas will be created at the same time. Then rename the canvas as "Level Menu UI" and the image as "Background"
30_2.png


Then for the Image
31_2.png

Level Buttons

Now that we have the background we will now add the buttons that will proceed as to next level. First create a new GameObject called it Level Button Holder this will hold all the buttons. After that create a buttons(15) as a children of the newly created GameObject. Next is to add Image inside the button and set it component as shown below.

32_2.png


And for the Text just enter an increment number that correspond to your level selection. Once your done make sure it the same as shown below.
33_2.png

Creating Level Menu Controller

Now that we have the level menu ui, we will now create the Level Menu Controller just like what we did on the main menu. The Level Menu Controller handles the selection for the stages. To this just simply create a new GameObject name it as Level Menu Controller, then create a script and name it LevelMenuController.

Inside the Level Menu Controller script, create a certain variable that we will use. Write these variables inside the Main Menu Controller class.
  1. public

    bool

    [

    ]

    levels;
  2. public

    Button[

    ]

    levelButtons;

Then add this several methods to your script.
  1. // Use this for initialization
  2. void

    Start (

    )

    {
  3. InitilizeGameVariables (

    )

    ;
  4. }

  5. // Update is called once per frame
  6. void

    Update (

    )

    {
  7. if

    (

    Input.

    GetKeyDown

    (

    KeyCode.

    Escape

    )

    )

    {
  8. SceneManager.

    LoadScene

    (

    SceneManager.

    GetActiveScene

    (

    )

    .

    buildIndex

    -

    1

    )

    ;
  9. }
  10. }

  11. void

    InitilizeGameVariables(

    )

    {
  12. if

    (

    GameController.

    instance

    !=

    null

    )

    {
  13. levels =

    GameController.

    instance

    .

    levels

    ;

  14. for

    (

    int

    i =

    1

    ;

    i <

    levels.

    Length

    ;

    i++

    )

    {
  15. if

    (

    levels [

    i]

    )

    {
  16. levelButtons [

    i]

    .

    transform

    .

    GetChild

    (

    1

    )

    .

    transform

    .

    gameObject

    .

    SetActive

    (

    false

    )

    ;
  17. }

    else

    {
  18. levelButtons [

    i]

    .

    interactable

    =

    false

    ;
  19. }
  20. }
  21. }

  22. }

  23. public

    void

    LevelSelect(

    )

    {
  24. string

    level =

    UnityEngine.

    EventSystems

    .

    EventSystem

    .

    current

    .

    currentSelectedGameObject

    .

    name

    ;

  25. switch

    (

    level)

    {
  26. case

    "Level 1"

    :
  27. if

    (

    GameController.

    instance

    !=

    null

    )

    {
  28. GameController.

    instance

    .

    currentLevel

    =

    1

    ;
  29. }
  30. break

    ;

  31. case

    "Level 2"

    :
  32. if

    (

    GameController.

    instance

    !=

    null

    )

    {
  33. GameController.

    instance

    .

    currentLevel

    =

    2

    ;
  34. }
  35. break

    ;

  36. case

    "Level 3"

    :
  37. if

    (

    GameController.

    instance

    !=

    null

    )

    {
  38. GameController.

    instance

    .

    currentLevel

    =

    3

    ;
  39. }
  40. break

    ;

  41. case

    "Level 4"

    :
  42. if

    (

    GameController.

    instance

    !=

    null

    )

    {
  43. GameController.

    instance

    .

    currentLevel

    =

    4

    ;
  44. }
  45. break

    ;

  46. case

    "Level 5"

    :
  47. if

    (

    GameController.

    instance

    !=

    null

    )

    {
  48. GameController.

    instance

    .

    currentLevel

    =

    5

    ;
  49. }
  50. break

    ;

  51. case

    "Level 6"

    :
  52. if

    (

    GameController.

    instance

    !=

    null

    )

    {
  53. GameController.

    instance

    .

    currentLevel

    =

    6

    ;
  54. }
  55. break

    ;

  56. case

    "Level 7"

    :
  57. if

    (

    GameController.

    instance

    !=

    null

    )

    {
  58. GameController.

    instance

    .

    currentLevel

    =

    7

    ;
  59. }
  60. break

    ;

  61. case

    "Level 8"

    :
  62. if

    (

    GameController.

    instance

    !=

    null

    )

    {
  63. GameController.

    instance

    .

    currentLevel

    =

    8

    ;
  64. }
  65. break

    ;

  66. case

    "Level 9"

    :
  67. if

    (

    GameController.

    instance

    !=

    null

    )

    {
  68. GameController.

    instance

    .

    currentLevel

    =

    9

    ;
  69. }
  70. break

    ;

  71. case

    "Level 10"

    :
  72. if

    (

    GameController.

    instance

    !=

    null

    )

    {
  73. GameController.

    instance

    .

    currentLevel

    =

    10

    ;
  74. }
  75. break

    ;

  76. case

    "Level 11"

    :
  77. if

    (

    GameController.

    instance

    !=

    null

    )

    {
  78. GameController.

    instance

    .

    currentLevel

    =

    11

    ;
  79. }
  80. break

    ;

  81. case

    "Level 12"

    :
  82. if

    (

    GameController.

    instance

    !=

    null

    )

    {
  83. GameController.

    instance

    .

    currentLevel

    =

    12

    ;
  84. }
  85. break

    ;

  86. case

    "Level 13"

    :
  87. if

    (

    GameController.

    instance

    !=

    null

    )

    {
  88. GameController.

    instance

    .

    currentLevel

    =

    13

    ;
  89. }
  90. break

    ;

  91. case

    "Level 14"

    :
  92. if

    (

    GameController.

    instance

    !=

    null

    )

    {
  93. GameController.

    instance

    .

    currentLevel

    =

    14

    ;
  94. }
  95. break

    ;

  96. case

    "Level 15"

    :
  97. if

    (

    GameController.

    instance

    !=

    null

    )

    {
  98. GameController.

    instance

    .

    currentLevel

    =

    15

    ;
  99. }
  100. break

    ;

  101. }

  102. SceneManager.

    LoadScene

    (

    level)

    ;

  103. }

After that attach the script to the Level Menu Controller GameObject, then also attach all the necessary Objects in the script.
34_1.png


Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.

2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.


Download
You must upgrade your account or reply in the thread to view the hidden content.
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

452,500

350,639

350,649

Top