static void SetScriptingBackendFromEnv(BuildTarget platform)
    {
        var targetGroup = BuildPipeline.GetBuildTargetGroup(platform);

        if (TryGetEnv(SCRIPTING_BACKEND_ENV_VAR, out string scriptingBackend))
        {
            if (scriptingBackend.TryConvertToEnum(out ScriptingImplementation backend))
            {
                Console.WriteLine($":: Setting ScriptingBackend to {backend}");
                PlayerSettings.SetScriptingBackend(targetGroup, backend);
            }
            else
            {
                string possibleValues = string.Join(", ",
                                                    Enum.GetValues(typeof(ScriptingImplementation)).Cast <ScriptingImplementation>());
                throw new Exception(
                          $"Could not find '{scriptingBackend}' in ScriptingImplementation enum. Possible values are: {possibleValues}");
            }
        }
        else
        {
            var defaultBackend = PlayerSettings.GetDefaultScriptingBackend(targetGroup);
            Console.WriteLine(
                $":: Using project's configured ScriptingBackend (should be {defaultBackend} for tagetGroup {targetGroup}");
        }
    }
Example #2
0
        public static bool IsScriptingImplementationSupported(ScriptingImplementation implementation, BuildTargetGroup target)
        {
            if (InspectorWindowType == null)
            {
                Debug.LogError(EditorTools.ConstructError("Couldn't find ModuleManager type!"));
                return(false);
            }

            if (ScriptingImplementationsType == null)
            {
                Debug.LogError(EditorTools.ConstructError("Couldn't find IScriptingImplementationsType type!"));
                return(false);
            }

            if (getScriptingImplementationsDelegate == null)
            {
                var mi = InspectorWindowType.GetMethod("GetScriptingImplementations", BindingFlags.Static | BindingFlags.NonPublic, Type.DefaultBinder, new [] { BuildTargetGroupType }, null);
                if (mi == null)
                {
                    Debug.LogError(EditorTools.ConstructError("Couldn't find GetScriptingImplementations method!"));
                    return(false);
                }
                getScriptingImplementationsDelegate = (GetScriptingImplementations)Delegate.CreateDelegate(typeof(GetScriptingImplementations), mi);
            }

            var result = getScriptingImplementationsDelegate.Invoke(target);

            if (result == null)             // happens for default platform support module
            {
#if UNITY_2018_1_OR_NEWER
                return(PlayerSettings.GetDefaultScriptingBackend(target) == implementation);
#else
                return(true);
#endif
            }

            if (scriptingImplementationsTypeEnabledMethodInfo == null)
            {
                scriptingImplementationsTypeEnabledMethodInfo = ScriptingImplementationsType.GetMethod("Enabled", BindingFlags.Public | BindingFlags.Instance);
                if (scriptingImplementationsTypeEnabledMethodInfo == null)
                {
                    Debug.LogError(EditorTools.ConstructError("Couldn't find IScriptingImplementations.Enabled() method!"));
                    return(false);
                }
            }

            var enabledImplementations = (ScriptingImplementation[])scriptingImplementationsTypeEnabledMethodInfo.Invoke(result, null);
            return(Array.IndexOf(enabledImplementations, implementation) != -1);
        }