Posts Tagged ‘Image’
Unity: How to make an overview map
Posted by Dimitri | Filed under Programming
This Unity tutorial explains the required steps to create a map that displays the level in a top-down view. For a real-time, precise map, an orthographic camera can be placed on the top of the map and set to exclusively render a specific layer. However, this post isn’t about creating a precise map, instead it shows how to create a stylized one. A Unity project with everything explained here is available for download at the end of this tutorial.
The first step is to create a plane by clicking on GameObject->Create Other->Plane. Resize it underneath your level, making it have the same size of your scene, not bigger or smaller, just enough to fit all of the elements inside it. (more…)
Android: take a picture without displaying a preview
Posted by Dimitri | Filed under Programming
Accessing hardware functionality when programming for an Android device is generally quite straightforward. The same can be said about writing an Activity that takes a picture, but Android requires a preview of what the camera will capture to be displayed prior to capturing an image. This post explains how to “cheat” this requirement imposed by the OS, and how to write an application that takes a picture and displays it.
An Eclipse project with all the code explained here is available for download at the end of the post.
Before going into the Activity code, the interface layout (the main.xml file) must be edited to add a Surface View and an Image View to the interface. To add an element, just drag and drop it from the list inside your layout, like this: (more…)
Unity: Creating a simple billboard
Posted by Dimitri | Filed under Programming
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…)
Android: How to return RGB values from an image file
Posted by Dimitri | Filed under Programming
Surprisingly, it’s quite easy to get the RGB value from an image file in Android. It’s certainly a lot easier than retrieving the pixel values from the Camera Preview. All that is required is to load the image file into a Bitmap object and them call the getPixel() method from the loaded bitmap.
It’s also possible to call this method to create an array of alpha and RGB values (ARGB) without calling the copyPixelsToBuffer() method, avoiding the use of buffers in Android which make things more complicated than it should be. As an example, the following code prints the color values of the pixels from the 4 corners of the image in LogCat and creates a RGBA array that stores each pixel color value:
Unity: How to create a GUI Sprite Sheet – Part 3
Posted by Dimitri | Filed under Featured, Programming
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: