๐ป 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
Resourcesasset, so mark it dirty and save before the build reads it. Revert it afterwards (or inOnPostprocessBuild) 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 defineNJCONSOLE_DISABLEto 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_DISABLEtoo, 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_DISABLEin 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();
}
}