Monday, 9 November 2015

UI Card Game

Over the next 3 weeks I'm going to be taught how to use the UI system in Unity to it's full capabilities. The game is a simple copy of a card matching game where you flip the cards to try and find the pairs. This first week covered the basics of the new Unity canvas system and how to make a menu from it. The first step was to add the background for our menu that everything else will be laid on top of. I needed to play around with the anchoring to make sure the background covered the whole screen upon playing the game.

The next focus was adding buttons so the player can navigate from the main menu to the actual game.
Buttons in Unity 5 are far easier to use because they come with a preset OnClick() section. All I had to do in order to make a working button was create a script containing no more than:

public void LoadLevel(int _levelIndex)
    {
        Application.LoadLevel (_levelIndex);
    }

This is all that is needed to create a loading button. I checked the build settings so I new which scene had which number, then added the script and game number into the button script. When I started up the game and pressed play, it took me straight into the game scene. I then just needed to position the button using anchors again then add a title and I had finished the main menu.
Finished menu screen

No comments:

Post a Comment