Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by blacksuit_films · Aug 10, 2011 at 09:11 PM · c#javascripttranslate

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;
     }
 }
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image blacksuit_films · Aug 10, 2011 at 10:25 PM 0
Share

I apologize if I seemed abrupt there, truth is I did try but have never touched C#, seemed easier to post the original code than the hash job I made. Thanks so much for your help too, It's well appreciated. I'm pretty new to forums as it is and It takes a bit of getting used to. What can I do to sort out my code highlighting? I don't see the problem.

All the best

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · Aug 10, 2011 at 10:17 PM

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;
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
-1

Answer by zarfishan · May 24, 2012 at 07:56 AM

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.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image save · May 24, 2012 at 07:58 AM 2
Share

That is not going to fly with Unity as Java isn't the same as JavaScript - which really should be called UnityScript to not confuse even further.

avatar image Lo0NuhtiK · May 24, 2012 at 11:56 PM 0
Share

The main topic title does say java though, looks like they just didn't want to read the rest of the question post before answering.

avatar image schult777 · Mar 07, 2014 at 06:47 AM 0
Share

the link does not work

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

About "translating" js into C# 1 Answer

Translate Unity-scripts to uScript 1 Answer

java to C# conversion 1 Answer

Translate code from C# to Javascript 1 Answer

Converting Variable to C# 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges