Hey… Is there any program to convert a C# script into a JS (for unity script)?
Thank you in advance
public class LuciMat : MonoBehaviour {
public Material material1;
public Material material2;
public Material currMaterial;
public KeyCode controlKey = KeyCode.X;
void Start () {
GetComponent<Renderer>().material = material1;
currMaterial = material1;
}
void Update () {
if (Input.GetKeyDown (controlKey))
{
if (currMaterial != material1)
{
GetComponent<Renderer>().material = material1;
currMaterial = material1;
}
else
{
GetComponent<Renderer>().material = material2;
currMaterial = material2;
}
}
}
}
Hi, I found this conversor:
http://www.m2h.nl/files/js_to_c.php
But I cannot assure that will work for any case. Try do it yourself, so you can learn a new programming language. I hope this was useful. Good Luck!
I don’t know of any free ones which work well.
There is this one on the asset store Unity Asset Store - The Best Assets for Game Making (paid for)
Or as brunobiluca said you could try it yourself.
Here is the translated script anyway:
#pragma strict
public var material1 : Material;
public var material2 : Material;
public var currMaterial : Material;
public var controlKey : KeyCode = KeyCode.X;
function Start () {
gameObject.GetComponent(Renderer).material = material1;
currMaterial = material1;
}
function Update () {
if (Input.GetKeyDown (controlKey))
{
if (currMaterial != material1)
{
gameObject.GetComponent(Renderer).material = material1;
currMaterial = material1;
}
else
{
gameObject.GetComponent(Renderer).material = material2;
currMaterial = material2;
}
}
}