Hi,
I’ve been struggling for the past few days in trying to understand the compilation order. Here’s my current understanding of how it works:
-
- All JS scripts inside Standard Assets Plugins.
-
- All C# scripts inside Standard Assets Plugins.
-
- All JS scripts outside Standard Assets Plugins Folder.
-
- All C# scripts outside Standard Assets Plugins Folder.
-
- All JS scripts inside the Editor folders.
-
- All C# scripts inside the Editor folders.
If JS is compiled before C#, then C# should be able to directly talk to JS; but this isn’t the case…
But here’s another question, how does boo fit into all of this? Is it before JS or after?
JS isn’t compiled before C#. This is the complete script compilation order overview; Boo fits into it the same way as JS and C#. You must use different “magic” folders (such as Standard Assets and Plugins) to control the compilation order; there is no other way.
–Eric
Okay, I thought that that document was outdated (because UT doesn’t even use Pro Standard Assets anymore, it’s all just Standard Assets). You say that JS isn’t compiled before C#, then it must be after, right? That means that JS should be able to talk to C# then, but it can’t (of course without using “special” folders). Why can’t JS talk to C# directly?
bump
To clarify my question a bit, what I want to know is why can’t JS talk directly to C# (when not in any magic folders of course)? C# is compiled first, right?
No. Or rather, it doesn’t matter (and is undefined); the “magic” folders are the only way to control what gets compiled first. There really is no other way. Relying on some kind of arbitrary order for what language is compiled first/second/third would be horribly messy, even more so than the magic folder system already is.
–Eric
Alrighty then, I never realized that it was kind of an unknown as to which language gets compiled first. If that’s the way it is, then no problem. Thanks!
P.S.: Something bizarre is going on in that you can actually name your javascript class the same exact name as your c# class, and it won’t cause any compiler errors. A further explanation would be nice, but no big deal.