Presentation is loading. Please wait.

Presentation is loading. Please wait.

Create a Simple UI Game in 10 Steps

Similar presentations


Presentation on theme: "Create a Simple UI Game in 10 Steps"— Presentation transcript:

1 Create a Simple UI Game in 10 Steps
Guess the Number Create a Simple UI Game in 10 Steps These slides are designed for Game Design Class Science and Culture University By Alireza Seddighi.

2 Step 1 Create Input field Select canvas
From “render mode” in inspector Select “screen space – camera “ Drop the main camera in “Render camera” From “Canvas scaler” in inspector Set the “UI Scale Mode” to “Scale with Screen Size” And also set the “Reference Resolution” to 1280*720 Also Set the match field to 0.5

3 Input Field Change the size Set the font size Adjust the Alignment

4 Step2 :Create the Necessary folders
Script Folder Scene Folder Save the current Scene with a propitiate name

5 Step3: Add extra Component to the canvas
Select the “Canvas” from “Hierarchy tab” Right click and from “UI” Create Text Adjust the font and other features Button Adjust the Size and other features

6 Step4: Create an Script Create an script in script folder
Define 2 variable for Input field and Text Since we using UI we should include the corresponding Namespace “Using UnityEngine.UI;” Create variables Public InputField input; Public Text Text;

7 Step5: Create A Game Object
Through the “Game Object menu” Select Create Empty Rename the game object to Game Controller Drag the script to the game object By selecting the Game Controller drag the inputfield to the input spot from Incpector drag the Text to the Text from Inspector

8 Step6: Create 2 Private variable
Private int guessNumber; Prvate int userGuess;

9 Step7: Generate random number
Throgh the Start Function guessNumber = Random.Range(0,100); We don’t need the Update function so we delete or comment it

10 Step8: Create a function for button
Public void CheckGuess() { userGuess = int.parse(input.text); If (userGuess == GuessNUmber){ Text,text = “Cangradulation you guessed the right Number ”; }else if (userGuess > GuessNUmber){ Text,text = “your guess is greater than the right Number ”; Text,text = “your guess is less than the right Number ”; Input.text =“”; }

11 Step9: Attach the CheckGuess() function to the Button
Select the button Trough the inspector tab go to “Button (Script)” section Then from the “On Click()” Select the “+” Drag the gameoject to the empy field From the drop down list Select the CheckGuess()

12 Step10: Run the game and play
THE END


Download ppt "Create a Simple UI Game in 10 Steps"

Similar presentations


Ads by Google