ShortcutsCode-Completion in Unitron: Alt-Escape Debug-BreakDebug.Break(); // Obvious! Enable/disable GameObjectsgameObject.active=false; gameObject.active=true; // recursive gameObject.SetActiveRecursively(false); gameObject.SetActiveRecursively(true); Create buttons
function OnGUI() {
if( GUI.Button( Rect( x, y, w, h ), "Text" ) ) {
Debug.Print( "Button clicked!" );
}
}
Hide/show Game ObjectstheGameObject.renderer.enabled = true/false; Drag objects with the mouseSource: Unity for Flash Developers
var screenSpace;
var offset;
function OnMouseDown() {
screenSpace = Camera.main.WorldToScreenPoint(transform.position);
offset = transform.position - Camera.main.ScreenToWorldPoint(Vector3(Input.mousePosition.x, Input.mousePosition.y, screenSpace.z));
}
function OnMouseDrag() {
var curScreenSpace = Vector3(Input.mousePosition.x, Input.mousePosition.y, screenSpace.z);
var curPosition = Camera.main.ScreenToWorld(curScreenSpace) + offset;
transform.position = curPosition;
}
Linkdump |
Knowledge Base Game Development
Personal |
| Page last modified on July 24, 2009, at 11:22 PM |


