Domanda

I have a pretty huge code to convert from JS to C# because of a joystick that I am using and I know barely C# so I was wondering if you could help me.

I already converted the functions to void.
I just need help for the declaration, for example:

In Javascript it's :

var SpawnPoint : Transform;

Here is my source code

È stato utile?

Soluzione

Unityscript declarations, such as your example:

var SpawnPoint : Transform;

can be written in C# like this:

Transform SpawnPoint;

another example:

var myObject : GameObject;

is:

GameObject myObject;

You can see the pattern (I hope). Be warned however that there are quite a few other key differences. One such difference that springs to mind is the way Coroutines and the WaitForSeconds method are handled (which are a little more complicated in C#).

Thankfully the documentation on the unity3d site is quite thorough, and has examples in both languages for most of the stuff, so you shouldn't have too much trouble translating your code.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top