How do I check for the IL2CPP scripting backend/setting?
With my plugin, I have a couple of problems with [marshalling in] mono. These problems are okay in IL2CPP, (which is required anyway for ios now)
Can I check to make sure IL2CPP is set and throw, or print errors, or even better, compile-time errors if IL2PP is not selected?
Not completely sure what you're asking - do you mean during build time make sure it's using IL2CPP? If so then you might be able to create a custom build script that forces the options you want...
And... http://answers.unity3d.com/questions/892370/where-can-i-use-scriptingimplementation.html
Or... http://forum.unity3d.com/threads/buildpipeline-il2cpp-universal-architecture.301948/
$$anonymous$$ight be able to do something with that?
Answer by SoylentGraham · Aug 28, 2015 at 01:21 PM
Thanks to Dave Carlile and Graham, the king of unity support in the linked answer. (Obviously I'll have a better error message)
#if UNITY_EDITOR
UnityEditor.ScriptingImplementation backend = (UnityEditor.ScriptingImplementation)UnityEditor.PlayerSettings.GetPropertyInt("ScriptingBackend", UnityEditor.BuildTargetGroup.iOS);
if (backend != UnityEditor.ScriptingImplementation.IL2CPP) {
Debug.LogError ("Warning: If the scripting backend is not IL2CPP there may be problems");
}
#endif
Would be interested to know if anyone has any compile-time solutions, but an error when running in the editor is good enough for now :)
I do the custom build script - it creates a build menu for me and I do my builds with that. You can force all of the options you want, have different menu items for different types of builds, etc. You could do the SetPropertyInt to set the scripting implementation then call the build function. It can take a bit to set up, but it's pretty handy once it's working.
I don't really want to force build scripts or secretly change build settings on people for a plugin :/
Ah, yep, makes sense. Didn't know it was something that would end up out of your control. If your plugin has an editor interface it should be possible to display a message there as well.
Answer by codestage · May 11, 2019 at 10:43 PM
Here is a super simple way to check from the Editor code if current build settings have IL2CPP selected as a scripting backend:
public static bool IsIL2CPPEnabled()
{
return PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup) == ScriptingImplementation.IL2CPP;
}
Note, you can also set it in similar way, if target platform supports IL2CPP:
PlayerSettings.SetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup, ScriptingImplementation.IL2CPP);
Answer by ksg97031 · Apr 14, 2017 at 01:31 AM
It's new, support new version higher then 5.6
Android PlayerSettings.GetScriptingBackend(UnityEditor.BuildTargetGroup.Android);
IOS PlayerSettings.GetScriptingBackend(UnityEditor.BuildTargetGroup.iOS);
Your answer
Follow this Question
Related Questions
A simple 2D unity game facing Jerks/Lags 0 Answers
Drastically worse performance with IL2CPP compared to Mono on Android 1 Answer
Reading XML on Mono Fails - IL2CPP works?! 0 Answers
/SOLVED /il2cpp makes my app crash 0 Answers
How to fix apps containing an unsafe implementation of TrustManager 0 Answers