Posts Tagged ‘Unity3D’

Posts that contain information about Unity3D game engine.

Unity: Scaling the GUI based on the screen resolution

Click here to read Unity: Scaling the GUI based on the screen resolution

As hinted by other posts, here, you will find how to properly scale the GUI elements based on screen resolution. As one may have noticed, Unity doesn’t scale the GUI elements based on the screen resolution, requiring a script to do the job, which is explained in this post. I will assume that the reader already knows how to create and render GUI elements in Unity using the MonoBehaviour’s OnGUI() function and GUISkin objects.

The best way to explain how to properly scale a GUI element is through an example. That said, for this post, let’s assume that we wanted a yellow rectangle to be rendered at the top left and bottom right corners of the screen, like this: (more…)

Unity: Creating a simple billboard

Click here to read Unity: Creating a simple billboard

Sometimes, when creating a game, there is the need to use a billboard. In the Unity game engine there is no billboard rendering component, and that’s why this post is going to explain one of the options to do so, it’s advantages and disadvantages. It’s not going to require a single line of code, but it’s not going to be the most optimized option either. At the end of the post a Unity project with all the game objects and components configured here is available for download.

To make a billboard in Unity, there is basically three different options: (more…)

Unity: How to use a GUI Texture to play fullscreen videos

Click here to read Unity: How to use a GUI Texture to play fullscreen videos

Warning: this tutorial only works with Unity Pro because the free version doesn’t come with video playback support. The code was created and tested with Unity version 3.3. It won’t work for versions 2.6 and below (requires some adaptation).

This Unity post explains how to set up a GUI Texture at the Unity editor and the code necessary to play a fullscreen video, that can be used for the studio logo animation at the beginning of the game, the game’s intro or any other video that needs to take the whole screen. It also explains how to properly scale the video based on the screen dimensions. At the end of the post, a Unity project featuring all the code explained here is available for download.

(more…)

Unity: How to create a GUI Sprite Sheet – Part 3

Click here to read Unity: How to create a GUI Sprite Sheet – Part 3

The final part of a series that explains how to create a GUI Sprite Sheet in Unity. This post will focus on explaining how the code works. For those who haven’t read the first and second parts, please do before going any further. As most post series in this website, there is a download with everything that had been explained at the end of the post.

With all images and the GUI Skin already set at the Unity Editor, now we just need some code to render the GUI on the screen. The following script correctly renders separately each element from the sprite sheet, and it’s attached to the Main Camera:

(more…)

Unity: How to create a GUI Sprite Sheet – Part 2

Click here to read Unity: How to create a GUI Sprite Sheet – Part 2

This is the second part of a series that will explain how to create a GUI sprite sheet for Unity. For this part, we will take the images created in the first post and import them to Unity. Also, this post features how to correctly set the images to be part of a GUI Skin object so they can be used as part of a game’s interface.

After having all images correctly placed at the sprite sheet, create a new GUI Skin by right-clicking anywhere inside the Project tab and select the following: Create->GUI Skin. Then, import the images in Unity, by dragging and dropping them inside this tab. It’s a good idea to put everything GUI related at the same folder, like this: (more…)