IL2CPP

From PowerUI
Jump to: navigation, search

Platforms that use IL2CPP like WebGL and optionally mobiles need some special considerations.

Nitro Compiler

Firstly, you'll need to precompile all your Nitro and remove the Nitro compiler by ticking both boxes in Window > PowerUI > Nitro settings because IL2CPP errors if it encounters the libraries that the compiler uses.

Code Stripping turned on? Add Preserve

If you've got code stripping turned on, you'll need to add Preserve to the static methods that your UI uses, otherwise they'll be stripped out. Preserve can also be added more broadly if you want (i.e. preserve whole classes instead).

You can either use [UnityEngine.Scripting.Preserve] which requires at least Unity 5.4 or [Values.Preserve]:

[Values.Preserve]
public static void Hello(Dom.MouseEvent e){
   
    // This method won't be stripped out by IL2CPP.
    
}