Programming - page 3

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

Continue reading: “Unity: list files in a directory”

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

Continue reading: “Unity: assigning a texture to the cursor”

Unity: changing Editor settings from outside Unity

Click here to read Unity: changing Editor settings from outside Unity

This post is aimed specifically at those who have opened Unity only to find out that it is crashing because of some recently added problematic script on the project. The text below shows how to circumvent this problem by enabling the ‘Always Show Project Wizard‘ option without the need to launch Unity. This tutorial will focus on how to do it on a Windows machine, with Unity version 3.5.6f4 installed. Mac Unity developers should take a look at this thread on Unity Answers.

The most well known method to make Unity load straight into the Project Wizard is to hold the left ALT while double clicking on the Unity icon. As described, it will take Unity straight into the Project Wizard. That way, you can choose another project and them enable the ‘Always Show Project Wizard at Startup‘ option by selecting Edit->Preferences.

Unity Preferences - Always Show Project Wizard

Enable this option and Unity will open the Project Wizard every time it’s started.

Continue reading: “Unity: changing Editor settings from outside Unity”

Android: ADB remote emulator access

Click here to read Android: ADB remote emulator access

This post shows how to access an emulated Android device over a local area network, so you can test and debug applications on another computer. It’s a step by step explanation based on this thread on Stack Overflow. The main goal behind this post is to show just one of the possible ways of doing it. So, if you have a suggestion on how to improve or make this process more secure, please, feel free to comment below.

The technique described on this post has been tested on a computer with Windows 7 64 bit (the one that executes the emulator) and an Ubuntu virtual machine running on another computer. The Ubuntu PC is the one that is running Eclipse and the one where the applications are being coded. For the sake of simplicity, this tutorial will reference it as “dev machine“. The other PC, the one running Windows 7 64 bit, will execute the Android emulator, which will be remotely accessed. This PC will be referenced as “remote machine” from now on.

Continue reading: “Android: ADB remote emulator access”