Tuesday, July 12, 2011

Environment Painting


I thought I would try and practice some environment painting for fun!


Tuesday, July 5, 2011

Unity Project 3: Tools

Name:
Fredson Laguna
Timeframe:
(Start Date to End Date): 5.28.2011 - 7.02.2011


Project Detail - What did you do, exactly.

I recreated the folder structure to fit my workflow:
Audio
Audio/SoundEffects
Audio/Music
Materials
Material/Textures
Meshes
Fonts
Scenes
Scenes/For Tests
Scripts
Scripts/JavaScript
Scripts/C#
Packages

I noticed that Unity sorts the folders in alphabetical order so I decided to create root folders for some of the assets so that it would be easier for the eyes to navigate.

I decided to create 3 simple tools that I figured may be useful to me in future projects:

Select Objects By Tag (Shift+T)
In the event that the user wanted to select all objects that have the same tag they would just need to select one of the objects that have the desired tag and press Shift+T:


@MenuItem ("Project Tools/Select Objects By Tag #t" )

static function SelectTag()
{
///stores the selected GameObject into var name
var selectedObject : Object = Selection.activeObject;
var tag : String = selectedObject.tag;

//this will stored the game object's tag in var gos
var gos = GameObject.FindGameObjectsWithTag(tag);

//this will select all the game objects that have the tag of the initial selected object
Selection.objects = gos;
}
Hide/Unhide Objects (Shift+H)
The user can quickly enable or disable an object by selecting the object and pressing Shift+H:

@MenuItem ("Project Tools/HideUnhide Selected Objects #h" )
static function HideUnhide()
{
/// This will store the selected GameObjects into an GameObject[] array
/// Selection.gameObjects = selected objects
var selectedObjects : GameObject[] = Selection.gameObjects;
for (var go : GameObject in selectedObjects)
{
// If game object is enabled, disable it
if(go.active == true)
go.active = false;
// If game object is disabled, enable it
else
go.active = true;

AssetDatabase.Refresh();
}
}
Create material from selected texture (Shift+M)
The user can select a diffuse texture and create a material from it:

@MenuItem ("Project Tools/Create Material From Selected Textures #m" )
static function CreateMaterial()
{
// This creates a new material variable that uses the diffuse shader
var newMaterial : Material = new Material (Shader.Find("Diffuse"));
// Generates the new material and saves it in the assets folder upon creation
AssetDatabase.CreateAsset(newMaterial, "Assets/Materials/NewMaterial.mat");
// Creates a Texture2D with the name textures from the selected texture
var textures : Texture2D = Selection.activeObject as Texture2D;
// var textures is the texture assigned to the created material
newMaterial.mainTexture = textures;

AssetDatabase.Refresh();
}
Time Tool
For the time tool I actually created it twice using two different methods. In one I created one big function that uses switch case to access each command. I used Input.inputString as a variable that acted as a switch:

var input = Input.inputString;

function Timetools(input)
{
switch (input)
{
case "1":
do this;
break;
}
}

The second way I approached this project was I created an enumeration that uses switch case to access each time tool function:

enum TimeTools{DoNothing, StartTimeSwitch, FromLoadTimeSwitch, StopTimeSwitch, ContinueTimeSwitch, ResetTimeSwitch, CountDownTimeSwitch, ContinueTimeDownSwitch, AddToTimeOnceSwitch, AddToTimeMultiSwitch, ActualTimeSwitch}

var timeTools : TimeTools;
timeTools = TimeTools.DoNothing;

if(Input.GetKeyDown("1"))
timeTools = TimeTools.StartTimeSwitch;


switch(timeTools)
{
case TimeTools.StartTimeSwitch:
DoThis();
break;
}

Software Used:
Unity3D

Final Thoughts - Reflect for a moment(Postmortem)
This was another enjoyable project. Got to finally understand how tools are created in Unity. I am also pleased that I got to use enumerations and switch case since I've never used the two before until this project. Now I have a better understanding of how they work. At first this project was a bit overwhelming for me since it took a while for me to understand mod% but now I got the hang of it and now I also know how to use Input.inputString.

Break down your Time (Research, Art, Design, Coding, Playtesting)
Research: 15+ hrs.
Art: 1 hrs.
Design : 1-2 hrs.
Coding : 15+ hrs.
Playtesting : 1-2 hrs.