top of page
Writer's pictureKane Adams

Main Menu

Updated: Dec 12, 2022

I wanted to take a small break from the main workload and so I focused on creating the main menu scene that will be the first thing loaded and also where the player can customise the blueprints for the terrain they are wanting to create. I also used this time to try and create a load screen for when the level is being generated.


This scene has three separate panels:

  • The main screen

  • Customise terrain screen

  • Load screen


Main Screen

The main screen panel consists of a play button and an exit button, the exit button simply closes the game whereas the play button opens up the customise terrain screen ready for the player to start their game.


Main screen panel used to play or exit game
Main Screen

Customise Terrain Screen

The customise terrain screen is where the majority of the code for the scene is required, this is where the player can choose what seed they want to use and change the colours of the terrain regions before they can click generate and start playing the game.


Seed

They can type in seed into the input field which will be converted into a Hash code, or they can click on the toggle to activate randomise seed where it will pick one at random. To prevent errors due to no input, I have added code to say if the input is empty to default to a random seed.


Terrain colours

With terrain colours, I have allowed the option to change the RGB elements of the 4 regions (snow, rock, grass, sea). I have also provided buttons to return to default colours and a toggle to randomly generate them which chooses the colours once the terrain scene is loaded. I haven't given the player access to the alpha setting for colours as I didn't want the player to be able to turn the terrain transparent.


Customise screen panel that is opened before the player can generate the level to give the chance to change aspects of the world
Customise terrain screen

Loading Screen

Something I have noticed is that the game takes a long time to generate the terrain chunks when you play from the scene itself or when you are loading the scene from another. One of the ways I have used to prevent the user from thinking the game has crashed was to use a loading screen. I have got the new scene loading in the background and will only switch once the scene is set up. After I started loading the new scene, I opened the loading screen panel that simply says the word "Loading...".


Loading screen panel without the progress bar
Load Screen

I also added code to use a slider as a loading bar that shows the progress of the next scene that is to be loaded, however, this slider doesn't seem to update so I will have to investigate this further should I have the time. I have commented out the code related to the progress bar and hidden it until I can look into it but my theory based on research done in forums is the for loop for generating the meshes is preventing the Coroutine used for the progress bar from running. Regardless, the inclusion of the panel itself helps to assure the user that the game is loading, they just won't be able to see the progress.


Coroutine created to change the value for the loadbar slider to show how much of the scene has been generated
Progress bar coroutine


Don't Destroy On Load

To allow the player's preferences to be used for the generation of the mesh in the next scene, I have created a Don't Destroy On Load (DDOL) game object that can be used to store the variables entering the new scene. The variables that I am entering currently are whether we are using random seeds or colours as Booleans, a string for what the custom seed is, and colour variable types to store the colour for the specific land region.




13 views0 comments

Recent Posts

See All

コメント


bottom of page