Archive for the ‘Programming’ Category

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:

Continue reading: “Unity: How to create a GUI Sprite Sheet – Part 1”

Import STL libraries to the Android NDK code

Click here to read Import STL libraries to the Android NDK code

This is a quick tip for those who are beginning to write native Android code. As one may have noticed, it isn’t possible to use containers like, string, vector, list inside the NDK samples. These are all part of the STL (Standard Template Library), and are expected to be available when writing C++ code.

To add STL to your NDK code, locate the Application.mk file inside your project’s jni folder. If it isn’t there, create it. Please note that the Application.mk is not the Android.mk file! The Android.mk file instructs the compiler and the JNI on how NDK code should be handled. The Application.mk, works similarly as the Android manifest file for your NDK code, allowing the programmer to add permissions and define other applications’ properties, like such as ‘enabling’ the STL support.

Continue reading: “Import STL libraries to the Android NDK code”

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:

Android: changing the screen brightness

Click here to read Android: changing the screen brightness

This post will explain how to change the current system brightness with a seek bar GUI on Android devices. The code here featured only works on real devices, because it is not possible to see brightness changes on the emulator. Also, all the code explained here is available for download at the end of this post.

The first thing one must know is that Android system brightness value is applied to the screen’s backlight only when the screen turns on. This means that only after a boot up or awaking the phone from a sleeping state will make the screen as bright as the value defined by the System.SCREEN_BRIGHTNESS variable. Consequently, changing only that variable won’t be enough to preview the brightness level.

Continue reading: “Android: changing the screen brightness”

Android: Retrieving the Camera preview as a Pixel Array

Click here to read Android: Retrieving the Camera preview as a Pixel Array

This post explains how to take the live images created by Android’s camera preview feature and return them as a RGB array, that can be used to all sorts of things, like custom effects preview and real-time image filtering. This post used the CameraPreview class that already comes bundled with Android’s SDK because it has everything already set-up, that way is just a matter of inserting more code. The techniques shown here works with Android 2.1 and should work with versions 1.6 and 1.5.

The first thing to do is to import the API Demos project to your Workspace. To do that, in Eclipse, click File -> New -> Android Project. In the dialog that has just opened, give the project a name at the first field (like API Demos 8) and select ‘Create project from existing source’. Now browse to <Android SDK folder>\samples\android-7\ApiDemos. Finally, mark Android 2.1 as the Build Target and click Finish: Continue reading: “Android: Retrieving the Camera preview as a Pixel Array”