Hi everyone, i have a noob question to ask:
Is it possible to istantiate an object of type “namec#file” and use it in javascript?
ex:
var scriptCS : myCSfile;
scriptCS.method();
i’ve stryied everything but without success.
Hi everyone, i have a noob question to ask:
Is it possible to istantiate an object of type “namec#file” and use it in javascript?
ex:
var scriptCS : myCSfile;
scriptCS.method();
i’ve stryied everything but without success.
private var scriptCS = new myCSfile();
If you want to see examples of it, you could look at the perlin noise generator on the example project page. I believe it’s written in C#, yet called from javascript.
an object or monobehaviour?
the later would be searched the same way as JS components
In both cases the requirement is that the C# file is in a folder thats compiled before this JS files folder. The advanced topics hold more information, there are other threads on this topic (pretty recent ones) that will give you a link to it
Good morning Quietus, thank for fast response.
I’ve tryied your advice but unity give this error to me: Unknown identifier: ‘PlayerController’. I’ve copied the name class directly into my code… private var scriptController = new PlayerController();
i’m missing something?
Hi dreamora, i’ve moved up my *.cs file before my *.js but i got same error again…i have to do something specific step? thanks again
before in which way?
just moving it up in the folders won’t do it.
It needs to be in a specific folder to be handled in an earlier build step, the files are not compiled according the folder hierarchy
ah ok, it’s sounded stange to me.
do you know how to do that?
Try moving it to the plugins folder.
You can find the documentation for compile order at the above link.
It works,
thank’s man, you are a hero!
but i dont understand why i have to do that instead to tell unity wich files compile first by some syntax rule, like “#compile first” or something like that.
thanks again.
Because there is no way to do that between completely distinct assemblies.
theoretically all would end in a single assembly as unity is a single namespace but that would cause problems with JS, C# and Boo interaction so there are different steps.
Also plugins binders must be compiled before the rest or you couldn’t use any plugins.