Archive for the ‘Programming’ Category
Unity: Making a simple audio visualization
Posted by Dimitri | Filed under Programming
As stated in the title, this Unity programming tutorial shows how to create a simple audio visualizer. This post focuses on explaining the necessary requirements in obtaining the audio data from the current music being played, and how to process this data to create a audio visualization. It won’t have detailed explanations on how to create a specific effect for an audio visualization. The code featured below and the example project were created and tested in Unity 3.5.2 .
For this post, the audio spectrum data will be displayed as a line using a LineRenderer component and will also feature some cubes that will fall from the top of the waveform, much like the little white bars above the spectrum found on the Windows Media Player “Bars” visualization. However, this visualization will be 3D and not 2D and will render a waveform and not bars.
To achieve that, a script and the following elements will be required: Continue reading: “Unity: Making a simple audio visualization”
Unity: Creating GUI transitions
Posted by Dimitri | Filed under Programming
This Unity scripting tutorial shows how to manipulate the GUI system origin to create an animated transition, so you can make your GUI’s look more interesting. To keep things simple, this post shows how to create an horizontal transition between two Text Areas using a couple of buttons. All code featured below is available for download at the end of the post.
To achieve an animated transition, the origin of the GUI system must be manipulated. This is done by changing the elements of the matrix that sets the rendering reference point of the GUI elements. Conveniently, Unity allows us to do that by manipulating the GUI.matrix values. So, the script requires a Matrix4x4 object. Also, to make the code more readable, a Vector3 is going to be created, also making it easier to translate the GUI system origin. Here’s the script:
Continue reading: “Unity: Creating GUI transitions”
Unity: Animated texture from image sequence – Part 2
Posted by Dimitri | Filed under Featured, Programming
The second and last tutorial of a series that explains how to create an animated texture from a sequence of images in the Unity engine. This is a direct follow up of the previous post, so if you’ve missed it, please read it here. As the first post, the same disclaimer applies: for animating a texture with a small number of frames and/or small frame sizes, it’s better to join them into a single sprite sheet image and use this script. For video playback, use the MovieTexture (only available at Unity Pro).
Just as a reminder, this series is about creating an animated texture from multiple image files. In the previous post, a script loaded all image files into an array and then changed the texture of the game object it was attached to. Continue reading: “Unity: Animated texture from image sequence – Part 2”
Unity: Animated texture from image sequence – Part 1
Posted by Dimitri | Filed under Programming
This is the first tutorial of a series that explains how to create an animated texture from a sequence of images in the Unity engine. Before going into details on the script or the requirements necessary in order to make the animation work, please bear in mind that there are other alternatives available which will achieve the same results. For any animation with a small number of frames and/or small frame sizes, it’s recommended to join then into a single sprite sheet image and use this script. For video playback, please use the MovieTexture (only available at Unity Pro). However, if the animation doesn’t fit a 4096×4096 px image file, the script in this tutorial might be the solution.
Continue reading: “Unity: Animated texture from image sequence – Part 1”
Android: Creating a two color LED notification
Posted by Dimitri | Filed under Featured, Programming
Another programming tutorial, this time, showing how to make the built-in notification LED on a Android device continuously alternate between two colors. That said, by the time this article is being written, it’s recommended to try this code on a real Android device that has a notification LED instead of running the application on the emulator. Also, the Activity featured below has been created to work on devices with Android 2.0 or later. All code featured in this article is available for download at the end of the post.
To continuously change the colors of the LED, it’s necessary to create and initialize a Notification object that changes the LED colors and post this notification using a handle to the system’s notification service (using a instance of the NotificationManager class). The notification is then canceled, its LED color is changed and the notification is posted again and the process is repeated over and over making the colors swap back and forth. Continue reading: “Android: Creating a two color LED notification”