- Home /
c# to JavaScript how?
i would love it if someone code put this code into js would love them forever haha, but i would really appreciate it!
using UnityEngine;
using System.Collections;
public class MenuObject: MonoBehaviour
{
will quit the application
public bool isQuit = false;
void OnMouseEnter()
{
renderer.material.color = Color.red;
}
void OnMouseExit()
{
renderer.material.color = Color.white;
}
void OnMouseDown()
{
if(isQuit)
{
Application.Quit();
}
else
{
Application.LoadLevel(1);
}
}
}
Answer by oliver-jones · Sep 16, 2013 at 07:36 PM
This is so easy it's untrue, which kind'a makes me suggest you're just being lazy?? (I dunnooo?)
All you have to do is literally replace Void, with Function, and:
public bool isQuit = false;
To:
var isQuit : boolean = false;
You also want to remove the:
public class MenuObject: MonoBehaviour
{
As well as the closing '}'
Oh and you can remove the 'using' bit at the top
In terms of structure, yes - I don't know what you're trying to achieve though
Answer by magnusOP · Sep 16, 2013 at 07:47 PM
thank you oliver unlike dave you actually helped! as i said in the beginning i dont know what i'm doing! so thanks for pointing that out dave i thought it was obvious.
Thats quite alright. Also, this post ^ should be a comment (add new comment), do you see it under my question post? And not an answer post.
Also, remember to tick any correct answers you receive :)
Answer by magnusOP · Sep 16, 2013 at 08:07 PM
does this look right
#pragma strict
private var isQuit : boolean = false;
function OnMouseEnter()
{
renderer.material.color = Color.red;
}
function OnMouseExit()
{
renderer.material.color = Color.white;
}
function OnMouseDown()
{
if(isQuit)
{
Application.Quit();
}
else
{
Application.LoadLevel(1);
}
}
Your answer
Follow this Question
Related Questions
Camera Effect + Translating US to C# 3 Answers
Translate code from C# to Javascript 1 Answer
translate C# with => to unityscript 2 Answers
Converting Variable to C# 1 Answer
Create new plane and Raycast in C#? 1 Answer