hi there. i'm really bad at scripting. wrote this to give a restart per button to a racing game: function Update () { if (Input.GetButton ("Jump")) { Application.LoadLevel (0); } } the problem is, it will only restart ONCE. i guess it has to do with the "function Update ()", but i haven't found about this issue in forums or manual. this is probably really embarassing, but i would be glad if someone could give me a hint. thanks!
This is what I put into a text object to make it a button ... Code (csharp): function OnMouseDown () { /* load a specific scene by name */ Application.LoadLevel ("namegoeshere"); } And if you create a script with the following in it, and attach it to the text object, it'll change it's appearance on mouse over ... Code (csharp): /* This behavior script changes the material color to the highlightColor when the mouse hovers over the text. The highlightColor can be modified in the inspector. */ /* It also scales the object to be slightly larger on mouse enter, then back to normal size when the mouse leaves the object. */ var highlightColor = Color.yellow; function OnMouseEnter () { guiText.material.color = highlightColor; transform.localScale = Vector3 (1.2, 1.2, 1.2); } function OnMouseExit () { guiText.material.color = Color.white; transform.localScale = Vector3 (1, 1, 1); }
thanks, david, but i think i formulated the question wrong, sorry! the level is reloaded if the player presses e.g. space ("jump") now (no need for a on-screen button), but it will only do this once. if you manage to crash the car A 2ND TIME, you'll not be able to reload the scene anymore.
Is this script attached to a game object in the racing level scene? Does the game object you attached the script to disappear when loading the level?