C# to java translation

Hi Can anyone translate this code to javascript for me?

I’m trying to get the script so when a url is typed into a textfield it recognises it and makes it into a hyper linke. I’d really appreciate some help with this one.

using UnityEngine;

public class Example : MonoBehaviour
{
    string url = "http://www.unity3d.com";
    void OnGUI()
    {
        url = GUILayout.TextField(url, GUILayout.Width(200));
        if (IsLink(url)) // Is it a link?
        {
            // Then show the submit button...
            if (GUILayout.Button("Submit", GUILayout.Width(200)))
            {
                // do something with url...
            }
        }
    }

    bool IsLink(string text)
    {
        if (text.StartsWith("http://") || text.StartsWith("www"))
            return true;
        else
            return false;
    }
}

That’s quite easy, but you shouldn’t just ask for someone to write the script for your. Try it yourself and if your have a “real” question / problem come here. Also watch your code highlighting.

var url = "http://www.unity3d.com";
function OnGUI()
{
    url = GUILayout.TextField(url, GUILayout.Width(200));
    if (IsLink(url)) // Is it a link?
    {
        // Then show the submit button...
        if (GUILayout.Button("Submit", GUILayout.Width(200)))
        {
            // do something with url...
        }
    }
}

function IsLink(text : String) : boolean
{
    if (text.StartsWith("http://") || text.StartsWith("www"))
        return true;
    else
        return false;
}

you can convert you C# code to java using this free tool C# to java converter available online. its a cloud App so no need to install or download it just upload your code and it will be converter to java instantly.