Unity Scripts
Menu Music/Game Objects passing between scenes
by David on May.20, 2010, under Unity Scripts
This is a very useful script to use when you want to be able to choose when / how to pass a game object onto another scene and then be able to return to a previous scene without ending up with duplicate objects.
(The script was taken from Unity Answers area on their site at the address below:)
http://answers.unity3d.com/questions/3863/audio-or-music-to-continue-playing-between-scene-changes
private static var instance:MusicHandler;
public static function GetInstance() : MusicHandler
{
return Read more [...]
Leave a Comment
:programming, scripts, Unity
more...
Simple HUD for Score & Lives in Unity
by David on Apr.28, 2010, under Unity, Unity Scripts
To create a simple HUD in a Unity game for Score and Lives:
Utilising the Unity GUI system (avoid this for things like Iphone development).
Uses "On GUI()" - function that can run multiple times per frame depending on user input.
All GUI code must be inside 'OnGUI' or else called from 'OnGUI' (in the case of separate functions to call based on cases)
public int score = 0;
public int lives = 3;
//could use: public static int score and lives if I only had one player so that you aren't Read more [...]
Leave a Comment
:HUD, Unity
more...
Unity – Accessing Components
by David on Apr.25, 2010, under Unity, Unity Scripts
Straight from the Unity Site here:
-------------------------------------------------------------
Components are attached to game objects. Attaching a Renderer component to a game object is what makes it render on the screen, attaching a Camera turns it into a camera object. All scripts are components thus they can be attached to game objects.
The most common components are accessible as simple member variables:
Component
Accessible as
Transform
transform
Rigidbody
rigidbody
Renderer
renderer
Camera
camera Read more [...]
Leave a Comment
:programming, script, Unity
more...
Player Script in Unity
by David on Apr.23, 2010, under Unity Scripts
Creating a simple Character Script
Great Tutorial - Part 1 here: http://www.3dbuzz.com/vbforum/sv_showvideo.php?v=3593
Overwritable Scripts:
Start() - gets called first
Awake() - gets called right before first update
Update() - gets called every frame
(also all of your onMouseOver/enter/trigger/collision etc..)
This script is a simple component..
------------------------------
PLAYER.JS
public float PlayerSpeed;
void Start() //this is what happens before anything else.
{
transform.position Read more [...]
Leave a Comment
:programming, scripts, Unity
more...
Creating an Inventory in Unity
by David on Dec.22, 2009, under Unity, Unity Scripts
Research into creating an inventory in Unity...
----------------------------Taken from this site:--------------------------
http://unity3d.com/support/documentation/ScriptReference/GUI.SelectionGrid.html
GUI.SelectionGrid
static function SelectionGrid (position : Rect, selected : int, texts : string[], xCount : int) : int
static function SelectionGrid (position : Rect, selected : int, images : Texture[], xCount : int) : int
static function SelectionGrid Read more [...]
Leave a Comment
:Games, Unity
more...

