Book Image

Unity 5 for Android Essentials

By : Valera Cogut
Book Image

Unity 5 for Android Essentials

By: Valera Cogut

Overview of this book

Table of Contents (14 chapters)
Unity 5 for Android Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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...