Which build options to choose!?

Hello,

There are so many scripting and API options to choose, I’m not sure which I should be picking. I’m currently writing a Windows Desktop, UWP and Android application but I’m not sure which of the run times and API’s I should be hitting. Can I even use IL2CPP on Windows Desktop? Does the API compatibility matter only for Visual Studio?

3350556--262070--upload_2018-1-11_17-55-42.png

If you don’t have any problems with 4.6 scripting runtime it is reported to be marginally faster. IL2CPP would be better for your final builds but the build time is slower so stick to mono for development builds. 2018.1 patch notes listed Windows Desktop IL2CPP support added so it should be okay, hopefully no bugs. API compatibility level - I’m not sure!

Does IL2CPP get any speed advantage when using 4.6 as .net framework, since it convert .net IL?
I mean IL2CPP with 2.0 vs IL2CPP with 4.6.

@00christian00

There is not a speed difference between the .NET profiles.

1 Like

Yes, starting the 2018.1, you can use IL2CPP as the scripting backend for Windows Desktop. This option is not available in older versions of Unity.

I’m not quite sure what you mean by this. In general though, The integration between Unity and Visual Studio will work for any scripting runtime version or API compatibility level.

I think there are a few questions you can answer to determine the proper values these settings.

JIT vs. AOT

First, do you want to to just-in-time compilation (JIT) or ahead-of-time compilation (AOT). JIT compilation is going to allow for a faster edit/compile/test cycle than AOT. Also, some normal .NET libraries rely on JIT, as the .NET Framework from Microsoft uses JIT compilation.

However you might need to use AOT compilation because some platform you are targeting requires it. In addition, AOT compilation can often lead to better runtime performance of your final executable (although this does depend on your project a good bit).

Since your stated platforms are Windows Desktop, Android, and UWP, I would recommend going with AOT. Windows Desktop and Android support both JIT and AOT, but UWP only supports AOT. What setting should you use? For the Scripting Backend setting.

Mono = JIT
IL2CPP = AOT

With that said, if you are just starting out with this project, Mono (for JIT) might be a better option. That will allow you to iterate more quickly. Once the project is more mature, you can make it work with IL2CPP in order to ship it on UWP.

.NET Profile (API Compatibility Level)

Second, you need to choose which .NET profile your code will compile against. The .NET profile is the API surface you can use for things in the .NET class libraries (e.g. types like List and OS APIs like files, threads, etc.). The .NET 4.6 profile has nearly everything supported by .NET 4.6 (which is a lot). You might need it all, but most projects don’t, so I would recommend starting with .NET Standard 2.0. That will make your final binary size significantly smaller than .NET 4.6 (the class library code is about half as large).

If you find that you need something in .NET 4.6 which is not in .NET Standard 2.0, then you can always switch later, because .NET Standard 2.0 is a proper subset of .NET 4.6.

3 Likes

Are there any (C# code) limitations with IL2CPP for windows desktop?

For example will it still be possitble to load a (c#) assembly at runtime (for example to load a game plugin or mod)?

Or can we say that anything that is supported with c#/JIT will also work in ILC2PP?

Yes, it general it has the restrictions of an AOT compiler. For example, System.Reflection.Emit is not supported.

It is only possible to load a C# assembly that was present when the Unity player build happened. It is not possible to load an assembly at runtime that was built separately.

What about the battery consumption for Android with IL2CPP? Is there any tests?

I’m not aware of any batter consumption comparisons, sorry.