Windows > ⨠Ninjadini Console
`
key (top-left on US keyboard). Press again to close.You can customize these triggers in Project Settings > Ninjadini ⨠Console
.
You can configure an access challenge to prevent unintended access to the console.
Add Access Challenge
Secret Pass
Apply changes
`
key press or hold at corner) it will stay hidden till it is activatedYou can disable auto start via Project Settings > Ninjadini ⨠Console > Playmode Overlay
To manually start the console overlay, call NjConsole.Overlay.EnsureStarted()
This will start hidden if you have activation triggers set up.
If you want to force show the console overlay, call NjConsole.Overlay.ShowWithAccessChallenge()
You can have your own custom way to trigger the console overlay in play mode.
The default triggers are done via ConsoleKeyPressTrigger and ConsolePressAndHoldTrigger, you can refer to them as example.
Project Settings > NjConsole > Playmode Overlay > Add Trigger
> add your new classApply changes
Example code below toggles the overlay on shift + right mouse click.
[System.Serializable]
public class ShiftRightClickConsoleTrigger : IConsoleOverlayTrigger, IConsoleExtension
{
ConsoleOverlay _overlay;
public void ListenForTriggers(ConsoleOverlay overlay)
{
_overlay = overlay;
overlay.schedule.Execute(Update).Every(1);
}
void Update()
{
// using old input manager...
if (Input.GetMouseButtonDown(1) && (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))) {
_overlay.Toggle();
}
}
}
You may want to set up your own access challenge, perhaps maybe tie it into your own login system.
Project Settings > NjConsole > Playmode Overlay > Add Access Challenge
> add your new classExample code below ask for a simple math question to answer before letting you go to console.
[System.Serializable]
public class MathsAccessChallenge : IConsoleAccessChallenge, IConsoleExtension
{
static bool _passed; // should be store in player pref or something
public bool ShowingChallenge { get; private set; }
void IConsoleModule.OnAdded(ConsoleModules console)
{
_passed = false;
ShowingChallenge = false;
}
public bool IsAccessChallengeRequired()
{
return !_passed;
}
public void ShowChallenge(Action callbackOnSuccess)
{
ShowingChallenge = true;
var numA = UnityEngine.Random.Range(1, 100);
var numB = UnityEngine.Random.Range(1, 100);
// This could be anything, like your own sign in dialog. We are just using the text prompt from Console for simplicity.
ConsoleTextPrompt.Show(new ConsoleTextPrompt.Data()
{
Title = $"{numA} + {numB} = ?",
ResultCallback = (response) =>
{
if (response == null) // user pressed close btn
{
ShowingChallenge = false;
return true;
}
if (int.TryParse(response, out var responseInt) && responseInt == numA + numB)
{
ShowingChallenge = false;
_passed = true;
callbackOnSuccess();
return true;
}
return false;
}
});
}
}