Hi guys,
this is my first post and my first game in unity… I already made the script running in javascript but now I have to translate it into c# to use the dll!
I created a C# file that import and process the contents of the dll…
Is there a way to pass values from C# to js or import c# script in the js file? or do I have completely rewrite the script?
I’m trying to rewrite it but I would be more difficult than I thought …
someone could help me?
importing isn’t required as all scripts in a unity project are within the same namespace.
all you have to do is ensure that the c# script is in a folder that is part of an earlier build step, you can check out the manual, it has an advanced topic entry on the build order etc
they can not be in the same folder.
as mentioned, the C# one needs to be in a folder thats compiled earlier.
If they are compiled in the same step they don’t exist for other languages than their own
I commonly put them into the Plugins folder which is the first one to be compiled in a project, cause “binding code” is by me handled the same way as real 3rd party API etc
It’s not possible for a JS and a C# script to work together like that when they are in the same directory.
You will either have to move the C# script to a directory that makes it compile before the JS script (Standard Assets/, for example), or perform all communication through SendMessage calls.
as any script its run when you tell it to run and assign it. otherwise it won’t
The plugins folder has no impact on how it works, only on when its compiled and thus what is able to use it
as for js using the variables: you can just get the component and access its public variables as if it were a js script
I’m very very sorry but I tried to write three methods to return the values in c #…
void Update () {
getEventID();
getXCoord();
getYCoord();
}
public int getEventID(){
return IsNewHolePresent();
}
public int getXCoord(){
return GetHoleXCoord(eventID);
}
public int getYCoord(){
return GetHoleYCoord(eventID);
}
But as before, when I call in js getXCoord() appears this error :