Posts Tagged ‘JavaScript’
These posts contain JavaScript code or are somehow related to JavaScript.
Unity: GUI Toggle Pair
Posted by Dimitri | Filed under Programming
This new (and brief) Unity programming post explains how to create a pair of GUI.Toggles that modifies the value of a single boolean. This means that, when one toggle is selected, the other one should be automatically set to unselected. This is best explained with an example, which can downloaded at the end of the post.
Unity: assigning a texture to the cursor
Posted by Dimitri | Filed under Programming
Unity 4.0 has been released last week and there are tons of new useful features to explore. One of those new fresh features is the option to set a Texture2D as a cursor. Although the code featured at the official documentation is extremely simple and explains how to achieve that with the OnMouseEnter() and the OnMouseExit() method, it will only work when the cursor is colliding with the 3D object in screen space. However, what if the game requires a default customized cursor that lasts throughout the whole level (or game)?
Unity: Capturing audio from a microphone
Posted by Dimitri | Filed under Programming
This Unity programming tutorial explains how to create a Unity script to capture the audio from a microphone. It also shows how to playback the captured audio and the necessary steps to check if there is a microphone present and its recording capabilities. The code featured in this post has been developed and tested using Unity 3.5.4f1 at the editor and a as a standalone Windows application. A sample project with all the code discussed in this tutorial is available for download at the end of the post.
To capture the audio input from a microphone in Unity, one can simply call the static Start() method from the Microphone class to start recording. This method returns an AudioClip that can be played back using an AudioSource. And that’s exactly what the script explained in this post will do. However, to avoid exceptions from being thrown, there is a simple verification to detect if there’s a microphone present prior to calling this method, and also, the mic audio capture capabilities are checked. Luckily, the same Microphone class also offers public members and methods that aid in accomplishing the two aforementioned tasks.
Android: Creating a WebView dialog
Posted by Dimitri | Filed under Featured, Programming
This Android post shows how to display a WebView inside a Dialog, that renders a website to the user. Since the WebView can load just about any web page, it’s possible to provide any information to users without launching the web browser, so they never have to leave the application.
For this tutorial, all code had been developed and tested in Android 2.1, both on an emulator and on a real device. As usual, an example application with the code featured in this tutorial is available for download at the end of the post.
The first thing required to place a WebView inside a dialog is to create a custom Dialog. After that, a WebView can be added to it. The easiest way to do that is to create a new Android layout file (in Eclipse, just right click the Project folder and select New -> Android XML file). Then, add the following code: (more…)
Unity: How to playback fullscreen videos using the GL class
Posted by Dimitri | Filed under Programming
This Unity programming tutorial explains how to use the immediate mode rendering available at the GL class for the playback of video files. There is already another post here on 41 Post that shows how to do the same thing using GUITexture component. However, in this tutorial, a quad is going to be rendered and the video will be played at its texture.
Not only the steps required for achieving fullscreen video playback are going to be explained, but how to properly scale the video based on the screen dimensions is also featured in this post. Warning: this tutorial works only with Unity Pro because the free version doesn’t support video decoding. This post has been created and tested in Unity version 3.4. At the end of the post, a Unity project featuring all the code explained here is available for download both in C# and JavaScript.