how to convert my java script to c# script?

#pragma strict

//Loading effect

public var loading : boolean = false;

var loadingTexture : Texture;

var size : float = 70.0;

private var rotAngle : float = 0.0;

var rotSpeed : float = 300.0;

function Update ()
{

if(loading)
    {

    	rotAngle += rotSpeed * Time.deltaTime;
    }	

}

function OnGUI()
{

    if(loading)
    {
	var pivot : Vector2 = Vector2(Screen.width/2, Screen.height/2);

	GUIUtility.RotateAroundPivot(rotAngle%360,pivot);

	GUI.DrawTexture(Rect ((Screen.width - size)/2 , (Screen.height 
            - size)/2, size, size), loadingTexture); 
}

}

im to weak in c# script so idont know how to convert it in c#. . i need it because my menu is made in C# and i want to get the boolean variable in this java script to c# but i dont know how? so the solution that i think is convert this to C# please help me? :( thankyou in advance!

1 Answer

1

http://www.m2h.nl/files/js_to_c.php

// Converted from UnityScript to C# at http://www.M2H.nl/files/js_to_c.php - by Mike Hergaarden
// Do test the code! You usually need to change a few small bits.

using UnityEngine;
using System.Collections;

public class MYCLASSNAME : MonoBehaviour {


//Loading effect

public bool  loading = false;

Texture loadingTexture;

float size = 70.0f;

private float rotAngle = 0.0f;

float rotSpeed = 300.0f;

void  Update (){


	if(loading)
        {

        	rotAngle += rotSpeed * Time.deltaTime;
        }	
}

void  OnGUI (){

        if(loading)
        {
		Vector2 pivot = Vector2(Screen.width/2, Screen.height/2);

		GUIUtility.RotateAroundPivot(rotAngle%360,pivot);

		GUI.DrawTexture( new Rect((Screen.width - size)/2 , (Screen.height 
                - size)/2, size, size), loadingTexture); 
	}
}

}

The generated code will have minor errors that you need to fix, such as on line 36, it should read Vector2 pivot = new Vector2(Screen.width/2, Screen.height/2); (the new keyword was missing). Also I think JS uses public variables by default so you'd need to make the ones that doesn't have public and private modifiers public.