Tag: User interface

Generate Project Folders Script

When creating a new project, use this simple script to generate all your folders:

// generate folders in our project
import System.IO;

@MenuItem ("Project Tools / MakeFolders #&_z")
// menuItem reads the first static function
static function MakeFolder()
{
GenerateFolders();
}

static function GenerateFolders ()
{

var projectPath : String = Application.dataPath + "/"; // store the path for the folders

// creating the folders
Directory.CreateDirectory(projectPath + "Audio");
Directory.CreateDirectory(projectPath + "Materials");
Directory.CreateDirectory(projectPath + "Meshes");
Directory.CreateDirectory(projectPath + "Resources");
Directory.CreateDirectory(projectPath + "Scripts");
Directory.CreateDirectory(projectPath + "Shaders");
Directory.CreateDirectory(projectPath + "GUI");
Directory.CreateDirectory(projectPath + "Textures");
Directory.CreateDirectory(projectPath + "Scenes");
Debug.Log ("Folders Created");

AssetDatabase.Refresh ();

}

Selection Script for Unity3D

This script is royalty free; you can use it for whatever you want to. What it does is when you click an object, the object is highlighted. When you click on it again, the object is un-highlighted, back to normal.

Just copy and paste this script into your JavaScript in Unity. Then attach the script to any visible object in your scene, including 3d text.

Here it is:

// Declare our variables...

var selectedColor : Color = Color(0.2, 0.3, 0.4); //This will give us a color wheel to choose a color from.
private var isSelected : boolean = false; // Simple boolean variable. Can be either true or false.

// Okay, now for the functions.
// The function OnMouseDown means to only do whats in the function when the user clicks the mouse.

function OnMouseDown ()
{
//isSelected = isNotSelected...
isSelected = !isSelected;

// If it's unselected, make sure the material color is white.
if (!isSelected) {
renderer.material.color = Color.white;

}

// If it's selected, change the material color to the selectedColor.
if (isSelected) {
renderer.material.color = selectedColor;

}

}

// Feel free to use this script in commercial or non-commercial purposes.
// My name in the credits somewhere would be appreciated, though.