• 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 Almith · Feb 19, 2014 at 02:33 PM · java to c#

What would this C# code snippet look like in java?

I'm fresh as could be when it comes to scripting. I'm leaning Unity through tutorials and I would rather be learning Java.

 using UnityEngine;
 using System.Collections;
 
 public class MainMenu : MonoBehaviour {
 
     public Texture backgroundTexture;
 
     void OnGUI(){
 
         //Display the image
         GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height),backgroundTexture);
 
 
         }
 
 }
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 GameVortex · Feb 19, 2014 at 02:44 PM 0
Share

Other than changing "using" to "import" and the ":" to "extends" there are not much other changes as Java and C# are very similar languages.

Unity does not support Java though, maybe you meant JavaScript/UnityScript?

1 Reply

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

Answer by Linus · Feb 19, 2014 at 03:00 PM

 #pragma strict
 //pragma strict not really required
 
  
 var backgroundTexture : Texture;
 
  
 function OnGUI(){
     //Display the image
     GUI.DrawTexture( Rect(0,0,Screen.width,Screen.height),backgroundTexture);
 }

Is the same code in UnityScript. Most will forgive you for calling UnityScript for JavaScript (since unity does so themselves), but do not call it Java ever again :)

Comment
Add comment · Show 2 · 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 Almith · Feb 20, 2014 at 11:28 AM 0
Share

I see! Please forgive me for my misunderstanding. lol. So, if I understand correctly, Javascript in Unity is basically UnityScript?

avatar image Linus · Feb 20, 2014 at 02:34 PM 0
Share

When JavaScript is mentioned in a Unity setting it is UnityScript.

But JavaScript in reality does not have anything todo with Unity, it is another scripting language completely. $$anonymous$$ost commonly used for web page scripting.

Here are more details on the differences http://wiki.unity3d.com/index.php?title=UnityScript_versus_JavaScript

Then there is Java, Java is not JavaScript or UnityScript. http://en.wikipedia.org/wiki/Java_%28program$$anonymous$$g_language%29

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

yield WaitForSeconds Giving off Error C# 1 Answer

Calling a Java function from C#: how can I pass a byte[] by reference into the Java function or return a byte[] by reference from the Java function? 0 Answers

Can you Help me about how to get the variable of Java Script to C# script? 2 Answers

How to print a hard-copy of a document in unity? 0 Answers

how can I insert code in a java application created with unity? 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