Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Unity 5 for Android Essentials

You're reading from   Unity 5 for Android Essentials A fast-paced guide to building impressive games and applications for Android devices with Unity 5

Arrow left icon
Product type Paperback
Published in Aug 2015
Publisher
ISBN-13 9781784399191
Length 200 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Valera Cogut Valera Cogut
Author Profile Icon Valera Cogut
Valera Cogut
Arrow right icon
View More author details
Toc

Transforming Unity C# code into Unity JavaScript code and vice versa


The following is an example of how easy it is to convert your Unity C# code to Unity JavaScript code and vice versa. You can find on the web a lot of different automatic tools that you can use for free in order get conversation between Unity Scripts done as early as possible. As an example, you can convert Unity JS to Unity C# on this http://www.m2h.nl/files/js_to_c.php.

JavaScript variables and types

By default, the Unity JS code variables are public and visible in Unity Inspector. In order to hide your variables from Unity inspector or from other classes, you should mark all those variables with a private keyword as shown in the following simple examples:

// private variables are invisible in Unity Inspector
private var length : float = 2.9;

// visible in Unity Inspector
var title : String = "Title";

// visible in Unity Inspector
var isLoop : boolean = false;

C# variables and types

Float values in C# must have a lowercase...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image