Hello, I urgently need help converting this JS script into C#? Thank You.
var isQuitButton = false;
function OnMouseEnter()
{
//change the colour of the text
renderer.material.color = Color.blue;
}
function OnMouseExit()
{
//change the colour of the text
renderer.material.color = Color.white;
}
function OnMouseUp()
{
//are we dealing with a Quit Button?
if( isQuitButton )
{
//quit the game
Application.Quit();
}
else
{
//load level
} Application.LoadLevel(1);
}
It’s really not that hard. Look what changed and try to do it yourself next time. It’s much much faster than asking here. It took me 4 minutes, which include reformatting your question.
using UnityEngine;
public class ThisJSSchriptInCS : MonoBehaviour
{
public bool isQuitButton = false;
private void OnMouseEnter()
{
//change the colour of the text
renderer.material.color = Color.blue;
}
private void OnMouseExit()
{
//change the colour of the text
renderer.material.color = Color.white;
}
private void OnMouseUp()
{
//are we dealing with a Quit Button?
if( isQuitButton )
{
//quit the game
Application.Quit();
}
else
{
//load level
Application.LoadLevel(1); // I assumed this one was misplaced
}
}
}