Posts Tagged ‘C Sharp’

These posts contain C# code or are somehow related to C#.

Unity: Animated texture from image sequence – Part 2

Click here to read Unity: Animated texture from image sequence – Part 2

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. (more…)

Unity: Animated texture from image sequence – Part 1

Click here to read Unity: Animated texture from image sequence – Part 1

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.

(more…)

Unity: How to playback fullscreen videos using the GL class

Click here to read Unity: How to playback fullscreen videos using the GL class

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.

(more…)

Unity: How to create a speech balloon

Click here to read Unity: How to create a speech balloon

This Unity tutorial explains how to create a speech balloon, like the ones featured on comic books, in Unity3D. For any game, objects move around the screen, and in order to make the speech bubbles work, they have to follow the movement of these objects. However, the balloon can’t be translated in the 3D space, or else it will look like a regular billboard sign over the character’s head. So, it has to follow the character on the two dimensional screen space. The elongated edge of the balloon must also follow the character’s movement, stretching and shrinking accordingly.

To solve these two issues, a script is necessary, which will treat the round part and the triangular tip of the balloon separately.

Speech balloon division

The script will create a speech balloon by rendering these two parts separately. They must have the same color to create the illusion that it's a single element.

(more…)

Unity: Creating a texture from a XML file

Click here to read Unity: Creating a texture from a XML file

This Unity3D programming tutorial explains how to read a XML file from the Resources folder and use the pixel color data defined there to create a Texture2D object. Basically, it’s the same as creating a texture from an array, but this array will be obtained from a XML file, instead of being defined in the script.

Since even a small image uses a large amount of tags on the XML file, an example project is available for download at the end of the post. This sample project has a XML file with 4096 items, that creates a 64×64 texture.

(more…)