๐Ÿ’ป Build customization

๐Ÿ”ง Dynamically Configure Console Features During Build

Same switches as Project Settings > Ninjadini โŒจ Console > Features โ€” you only need a build processor if they differ per platform or build flavour.

Field on ConsoleSettings Turns off in player builds
inPlayerLogsPanel Logs panel
inPlayerOptionsPanel Options panel
inPlayerHierarchyPanel Hierarchy panel
inPlayerUtilitiesPanel Utilities panel
inPlayerObjectInspector Object Inspector โ€” including log object links, hierarchy component detail and type search
inPlayerCommandLine Command Line
inPlayerKeyBindings Key bindings (off by default)
autoStartOverlay Auto-starting the runtime overlay

All of them are always on in the Editor.

The example below disables the Hierarchy and Object Inspector panels for WebGL builds.

public class NjConsoleSettingsBuildProcessor : IPreprocessBuildWithReport
{
    public int callbackOrder => 0;
    public void OnPreprocessBuild(BuildReport report)
    {
        var settings = ConsoleSettings.Get();
        var platform = report.summary.platform;

        settings.inPlayerObjectInspector = platform != BuildTarget.WebGL;
        settings.inPlayerHierarchyPanel = platform != BuildTarget.WebGL;

        EditorUtility.SetDirty(settings);
        AssetDatabase.SaveAssets();
    }
}

The settings live in a Resources asset, so mark it dirty and save before the build reads it. Revert it afterwards (or in OnPostprocessBuild) so the change doesnโ€™t leak into the next build.

โš ๏ธ Note: In production builds, a determined attacker could still enable console features via memory hacking.
For best security, use compile define NJCONSOLE_DISABLE to strip out the console completely. See next section for more info.

โœ‚๏ธ Disable / Strip NjConsole for Production

โœ… Benefits of Stripping

  • ๐Ÿง  Smaller build, less memory.
  • ๐Ÿ” Nothing to reverse engineer โ€” no console UI, no cheat options.
  • โœ… Recommended for production releases.

๐Ÿงฉ How It Works

  • โœ‚๏ธ NjConsole scripts are stripped behind #if !NJCONSOLE_DISABLE.
  • ๐Ÿงฑ Most interfaces and key classes are stubbed, so your project still compiles.
  • โ— Some advanced APIs are stripped entirely and must be wrapped yourself. See Hidden Gems for what is stubbed and what isnโ€™t.
  • ๐Ÿ”’ Wrap your own cheat/debug logic in #if !NJCONSOLE_DISABLE too, so itโ€™s stripped as well.
  • ๐Ÿ“‹ Log history is still collected in the background โ€” useful for crash reports and support diagnostics.

โœ‚๏ธ How to Disable NjConsole

  • ๐ŸŽ›๏ธ๏ธ UI Method: Go to Project Settings > Ninjadini โŒจ Console > Disable NjConsole
  • โœ๏ธ Manual Define: Add NJCONSOLE_DISABLE in Player Settings > Scripting Define Symbols.
  • ๐Ÿง‘โ€๐Ÿ’ป Code/API Method: Call ConsoleEditorSettings.AddDefineSymbolToDisableConsole()

This disables NjConsole for release builds and re-enables it afterwards:

using Ninjadini.Console.Editor;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;

public class NjConsoleBuildDisableProcessor : IPreprocessBuildWithReport, IPostprocessBuildWithReport
{
    public int callbackOrder => -1000;

    public void OnPreprocessBuild(BuildReport report)
    {
        var isDevelopmentBuild = (report.summary.options & BuildOptions.Development) != 0;
        if (isDevelopmentBuild) return; 
        // ^ Have your own conditional logic here. In this example, we only disable NjConsole in release (non-debug) builds.
        
        ConsoleEditorSettings.AddDefineSymbolToDisableConsole();
    }

    public void OnPostprocessBuild(BuildReport report)
    {
        // Reenable NjConsole.
        // Unfortunately, if the build failed, this code will not execute and you'll need to manually turn it on from Project Settings > Ninjadini โŒจ Console > Disable NjConsole.
        // This code is not needed if you are using a build box where you revert the changes after build.
        ConsoleEditorSettings.RemoveDefineSymbolAndEnableConsole();
    }
}

NjConsole doc home