Posts Tagged ‘C Sharp’

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

Unity: GUI Toggle Pair

Click here to read Unity: GUI Toggle Pair

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: animated ellipsis

Click here to read Unity: animated ellipsis

We have all seen it on loading screens of a variety of games and applications. I’m talking about animated ellipses, the animated three dots () on the end of a sentence which indicates that the game or software is being loaded.

This post explains how to make exactly that, an animated ellipsis in Unity. Here’s a video showing what the script on this post will do:


Unity: expandable GUI Window

Click here to read Unity: expandable GUI Window

This Unity programming tutorial shows how to create a GUI window that changes between two pre-determined sizes, in other words, an expandable GUI window that can be shrunk down, back to its original size. The code on this post has been developed using Unity 4.0.1f2, and an example project is available for download at the bottom of this page.

Unity’s GUI windows elements are very useful, not only because they can visually group various GUI elements, but also due to the possibility of repositioning it on the screen. For that reason, the script features some additional logic that allows for the windows to be resized at the correct position on the screen, even if it has been dragged by the user.

Here’s a short video of what the code below achieves:


Unity: list files in a directory

Click here to read Unity: list files in a directory

This Unity3D programming post explains how to create a C# script that lists the files in a directory. Additionally, for the sake of completeness, this post also shows a rudimentary method that allows to select one of the files from the list and how to deal with some of the potential IO errors.

Here’s a screenshot of the code in action:

Unity - List files in a directory - example project screenshot


Unity: assigning a texture to the cursor

Click here to read Unity: assigning a texture to the cursor

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)?