For this week’s class we
learned the new UI system unity, which is easy to use as it is more visual than
the old system in which you would have to hardcode almost everything in
script. We are supposed to apply the new UI system into our game and listed below
are the specifics –
1. The game should
have a main menu with a play button. It can have game artwork and any other
elements you wish to add. The play button should start the game. One the play
button is clicked. The menu should disappear.
2. The menu should also have a input field where
the player enters his/her name. Once the player presses play/ hits enter on the
keyboard, the menu should disappear and the name should appear on the status
bar or the HUD within the game.3. Create an infinite scrolling background for
the game.4. The HUD should also contain score/ distance
travelled
Firstly I started off with
the infinite scrolling background which were two quads made to look like
backgrounds and then we moved them along the X axis by going towards the –x
coordinates and would reset its position to the starting position so it would
look as the background is scrolling infinitely. While doing this I found a bug
in unity that it does not autocomplete keywords used in unity, which confused
me initially, but I reported it via the unity bug reporter and restarted unity which has temporarily stopped the problem .
Video of the infinite
background: -
https://www.youtube.com/watch?v=LFycTOxVM0A
Secondly I added the UI
elements such as score, distance and the players name .in order to take the
players name I made a script called game manager where I would update the text
based on the user's input but you would also need to add a name field where the
player can type input and pass the input to the script in my case I had added
the script to the Main camera and passed the camera onto the text input on the
canvas.
Note- in order to use anything related to the new UI system you need to have Using unityengine.UI learn more at (Unity , 2015)
Thirdly, I
got the score working same way as the name but I didn’t have to use the game
manager as I am currently using the player's distance travelled as score for now
later I shall multiply distance * coins collected. Though I had problems with
the play button, when I hit the play button the panel is not disabling which
was working before. Update :- had to make changes in the inspector in order to fix the problem .
Unity. (2015, July 24). Unity - Using the UI Tools. Retrieved from https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/using-the-ui-tools


No comments:
Post a Comment