I thought I read somewhere that you could not call C# from JavaScript, but I assumed that the two could otherwise peacefully coexist.
The following two screenshots seem to indicate otherwise. Earlier today, JavaScript would work but not C#. So I’m at a loss as to how Unity decides which language can be used.
One screenshot is from the Unity editor. It has a simple script that populates a text mesh with a string.
The other screenshot is from the same scene running on a Nokia Windows 8 phone.
Do I now need to make a decision on which language I want to use, and never mix the two, or is there something else going on?
Thank you, Dantaus. I’m pretty familiar with the ins and outs of mixing code. Unfortunately, it appears that mixed code breaks one half or the other on Windows.
This same project works flawlessly on iOS, Android, Mac, PC, and Web builds. It only goes south on the Windows 8 Phone build.
There are no issues at all mixing languages, as long as just you go one way. I use C# for “library” code (like static functions and so on) and Unityscript for “game/Unity” programming, since I’m far more productive using it than C# for that sort of thing.
The error suggests that you have somewhere code like this:
public class Test
{ #if UNITY_EDITOR
public float var; #endif
}
This creates a different serialization layouts, when you build WP8 from Editor, it will serialize var variable, but when you launch your app on WP8, the runtime doesn’t see the var variable, because assembly was compiled without UNITY_EDITOR, thus you read less data, than you should, on other platforms this was solved, but on Windows Store Apps/WP8, this issue is still, we might fix it for 4.5. But for now, you must be aware of such cases.
I’m exactly the same way. I don’t know if I’ve done anything in just Unityscript or just C# in four years. I’m glad to know I’m at least not the only one doing that
Enclosed is the scene and both of the scripts.
I hope this is something stupid I’m doing, but as of right now, I’ve tested everything I can think of. Please let me know what you find.
In the meantime I’m rewriting this app in C# so I can ship it already
I wouldn’t use Javascript at all for making Windows apps if I were you! There are a few bugs in compilation that are not fixed yet - especially involving strings. (4.2.1) You might get lucky and avoid those bugs but best to stick with C sharp.
This was a show stopper and ultimately the lack of a solution was a deal breaker for my client.
This was the first app in 20+ years of software development I was unable to ship, due to the development environment failing to work properly. I received very little to no helpful feedback for the issues I ran into, and I see the problems I reported were not fixed prior to v4.3 shipping.
Bummer, I think I’m seeing the same issue: everything runs great in the unity editor, and builds correctly in mono, and builds to other platforms, but give me errors when i build to windows … in this case i’m using CFInput (control pad item i bought from the store) and referencing it from my JS files, works great till i export to windows store, then all of a sudden it can’t find CFInput :sad:
error is /assets/scripts/robocontrollerscript.js(2,27): BCE0018: The name ‘TouchZone’ does not denote a valid type (‘not found’)
It works when building to other platforms, not sure why the win8store one fails. I’ve confirmed that the c# code is in the plugins, and i think putting this in assets/scripts should be ok?
Stick with C#. I don’t regret switching, my code is much cleaner now, and better designed due to the path c# sends you down. You’re forced to think a little more modular and this is beneficial long term.
TouchZone is not Unity API, which means you have it defined somewhere in your scripts. If it’s defined in C# scripts in your code and you want to use it from JavaScript, you will have set compilation overrides to “Use .NET Core partially” in player settings for Windows Store Apps.
Ah thanks for the replies! I ended up rewriting in c# and it works, I didn’t realize the “use .NET Core partially” setting, thanks for the info, if i’m in the same situation again I’ll try it!