Posts Tagged ‘Unity3D’

Posts that contain information about Unity3D game engine.

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

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

This post is the first of a series that explains how to create a GUI sprite sheet (a.k.a. atlas map) in the Unity game engine. This map consists of buttons, text areas, backgrounds and other interface elements joined together to create various joined image files with all interface elements inside it.

Here, the focus will be on how to prepare and create this images at an image editing software, which is the most important step. The next post of this series will explain how to import these images in Unity and place them inside a GUI Skin object.

The first thing to do is to have all the GUI elements needed for the game or specific part of the game. They have to be already created before building the sprite sheet, at least their size have to be already defined. Throughout this post, the following GUI elements will be used to exemplify how to correctly join the images together:

(more…)

Embedding the Unity Web Player with jQuery

Click here to read Embedding the Unity Web Player with jQuery

This post explains how to use jQuery to embed the Unity Web Player on a page. This post was inspired by GFX47, after reading this tweet. Here, you will find a step-by-step explanation on how to load the script on a HTML file. This will be achieved by using a jQuery plugin.

Unity3D already comes the tools to export a HTML file with all the code needed to embed the player. With that, one might be wondering what are the advantages of using jQuery to embed the Web Player. Here’s a list of advantages:

Using static variables in Unity3D

Click here to read Using static variables in Unity3D

This post explains how to use static variables when programming scripts for the Unity3D engine. The example scripts in this post are written in C#, but the same guidelines apply for JavaScript.

Before delving deeper into the subject, it goes without saying that static variables should be avoided at all costs, for a great number of reasons that can be easily be found on the internet. It’s better to use a Singleton creational pattern in most cases. with that in mind, here’s a short definition of static variables: they are variables that belong to a class, and not the objects the class creates. This means that static variables retain the same value, regardless of the object from a given class. Another characteristic is that, as long as the class is in the memory, they are still valid references. Static variables are initialized by the compiler right before the class creation, and before any other variables or methods. But what does it mean for Unity3D scripts?

(more…)

Unity3D: Creating a GUI with both 3D and 2D elements

Click here to read Unity3D: Creating a GUI with both 3D and 2D elements

This post explains how to create a GUI on the Unity3D game engine that has both 2D and 3D elements in it. Some may say that is just a matter of setting up a new camera with a dedicated culling mask just to render the 3D elements on the GUI. While this is partially true, adding a 2D image using a script with GUI function calls will cause the 3D image to be covered by the 2D image. That’s why this post will focus on how to set a GUI that has a 3D element with a 2D background.

As usual, at the end of the post, a Unity3D project is available for download with everything that was explained here.

(more…)

Using C# delegates in Unity3D scripts

Click here to read Using C# delegates in Unity3D scripts

When Unity3D 3.0 came out, it not only fixed a lot of bugs and added features, but it also upgraded the Mono version being used, including C# language features like namespace support, linq and delegates. This post is going to be about the latter, explaining what is a delegate and what benefits it could bring when using it to develop games on Unity3D.

Basically, in C#, a delegate is a reference to a method or to a group of methods that have the same signature (returns the same type and has the same parameters). A better explanation can be found at Microsoft’s MSDN C# documentation: (more…)