Closed Nezz closed 4 years ago
Would be able to describe your preprocessor approach in more detail? I'm not sure, I'm fully understand it.
Sure, here's an example:
public class BuildEnvironmentPreprocessor : IPreprocessBuildWithReport
{
public int callbackOrder => 1;
public void OnPreprocessBuild(BuildReport report)
{
var releaseBuild = Environment.GetCommandLineArgs().Any(arg => arg == "--release");
LunarConsolePluginInternal.LunarConsolePluginEditorHelper.SetLunarConsoleEnabled(!releaseBuild);
}
}
As far as I understand, this approach is for command line builds, right?
If you can run a command line before the build process you can do this:
<UNITY_BIN_PATH> -projectpath <PROJECT_PATH> -quit -batchmode -executeMethod LunarConsoleEditorInternal.Installer.DisablePlugin
For more information see this guide
Yes, this is for command line build. We run builds in a single Unity execution to save time since Unity has a large launch time overhead. That's why we are asking for a solution that works without recompiling the project.
Another option is to update Project/Assets/LunarConsole/Scripts/LunarConsole.cs
file manually: you need to replace #define LUNAR_CONSOLE_ENABLED
with #define LUNAR_CONSOLE_DISABLED
.
For more details see: disable_lunar_console.sh
I'll take a stab at implementing this and submit a PR. Should be reasonably easy to do.
Hey @Nezz,
Did you have a chance to look at it?
Yes, I'd have to make LunarConsoleConfig.consoleEnabled
non-readonly and move LunarConsolePluginEditorHelper.SetLunarConsoleEnabled
to the Editor assembly so it can call AndroidPlugin.SetEnabled
. Does this sound good on a high level? I can submit a PR early next week.
Should be fine for now. I'm planning to add Package Manger support and move away from preprocessor defines in 2.0.0 release.
We'd like to use a build preprocessor to toggle Lunar Console in our builds. We tried calling
LunarConsolePluginEditorHelper.SetLunarConsoleEnabled
, but we noticed that the libraries are still included in iOS and Android builds.Enabling and disabling the plugin seems to require the editor scripts to recompile first. Would it be possible to make it take effect immediately, so we can toggle Lunar Console from a preprocessor?