I wanna convert a C# script into UNITY Javascript. A lot of code is clear but there are a few lines where I stumble:
public enum CollisionStyle
{
Left,
Right
}
public LayerMask collisionLayers = new LayerMask();
public CollisionStyle c_Style = CollisionStyle.Left;
public Transform target;
Here I thought its
enum CollisionStyle {Left, Right};
var collisionLayers = new LayerMask() : LayerMask;
var c_Style : CollisionStyle = CollisionStyle.Left;
var target : Transform;
I get a “Parsing Error” at Line “var target : Transform;”
First thanks. The other Errors appears.
Now I have the following problems:
public List<Renderer> objectsToFade;
private List<Material> _faded_mats = new List<Material>();
private List<Material> _current_faded_mats = new List<Material>();
public bool Controllable
{
get { return _controllable; }
set { _controllable = value; }
}
foreach(Material m in r.materials)
set it to:
var objectsToFade : List[Renderer];
private var _faded_mats : List[Material] = new List[Material]();
private var _current_faded_mats : List[Material] = new List[Material]();
// Dont know what this is
public bool Controllable
{
get { return _controllable; }
set { _controllable = value; }
}
case of (Material m in r.materials)
private List<Material> _faded_mats = new List<Material>();
is a general linked list filled with objects of type Material so you cannot have another type of objects in that list.
I don’t know if in JavaScript you have a generic linked list collection but I think you can use:
private var _faded_mats : Material[];
but the think is that if you will need to push and pull from the array, you have to provide your own methods.
At this point my JavaScript knowledge is in a dead end because I don’t know how to use arrays.
Hi,
I just translate the C# Code into Java, cause I began to write in Java a Testgame, then I found a C# script which I can take and its helpful, but I just manipulate a variable in the C# Script with a Java-Script, but I don’t know how.
So for me it is helpfull to translate the C# Script into Java, and make one hole Java Script instead of one Java + 1 C# Script.
var objectsToRotate : List.<Transform> = new List.<Transform>();
On Wiki the decleration is just writen so, but UNITY 3.5.5 says: BCE0018: The name ‘List’ does not denote a valid type (‘not found’). Did you mean ‘UnityEngine.Light’?