call up a menu at any time by right-clicking

Posted: 07 Jul 2021 12:39
by KK2M

During the game, I want the player to call up a menu at any time by right-clicking on the screen,and to pause the text printer.
Also, I realize that a pauseUI has been created in the plugin. How do I get the player to call it in the game

thanks


Re: call up a menu at any time by right-clicking

Posted: 07 Jul 2021 18:43
by idaot

You can add your own custom input binding through a simple bit of C# scripting. You can use the listener scripts showcased in the Inventory Example project (https://github.com/Naninovel/Inventory/ ... UI.cs#L215) as the basis for this.

I also recommend checking out Engine Services, specifically IUIManager which contains publicly available methods for calling UI's in C#. https://naninovel.com/guide/engine-serv ... e-services


Re: call up a menu at any time by right-clicking

Posted: 08 Jul 2021 08:52
by KK2M
idaot wrote: 07 Jul 2021 18:43

You can add your own custom input binding through a simple bit of C# scripting. You can use the listener scripts showcased in the Inventory Example project (https://github.com/Naninovel/Inventory/ ... UI.cs#L215) as the basis for this and when done correctly, the new binding will show up under Naninovel's input configuration which you can bind to several inputs.

I also recommend checking out Engine Services, specifically IUIManager which contains publicly available methods for calling UI's in C#. https://naninovel.com/guide/engine-serv ... e-services

Oh!I've learned :D


Re: call up a menu at any time by right-clicking

Posted: 12 Jul 2021 15:29
by fyrrion
idaot wrote: 07 Jul 2021 18:43

You can add your own custom input binding through a simple bit of C# scripting. You can use the listener scripts showcased in the Inventory Example project (https://github.com/Naninovel/Inventory/ ... UI.cs#L215) as the basis for this and when done correctly, the new binding will show up under Naninovel's input configuration which you can bind to several inputs.

I also recommend checking out Engine Services, specifically IUIManager which contains publicly available methods for calling UI's in C#. https://naninovel.com/guide/engine-serv ... e-services

Is there no easier option to implement this? This is such a basic and elementary functionality for the convenience of players, which is needed in almost any novel. It's sad if you have to bother so much technically for such a simple function.: (


Re: call up a menu at any time by right-clicking

Posted: 13 Jul 2021 21:23
by idaot
fyrrion wrote: 12 Jul 2021 15:29
idaot wrote: 07 Jul 2021 18:43

You can add your own custom input binding through a simple bit of C# scripting. You can use the listener scripts showcased in the Inventory Example project (https://github.com/Naninovel/Inventory/ ... UI.cs#L215) as the basis for this and when done correctly, the new binding will show up under Naninovel's input configuration which you can bind to several inputs.

I also recommend checking out Engine Services, specifically IUIManager which contains publicly available methods for calling UI's in C#. https://naninovel.com/guide/engine-serv ... e-services

Is there no easier option to implement this? This is such a basic and elementary functionality for the convenience of players, which is needed in almost any novel. It's sad if you have to bother so much technically for such a simple function.: (

As far as C# is concerned, this is very simple. I highly recommend learning a bit of C# as the engine services provided with Naninovel will open up a lot of possibilities.

Here's a code that can be attached to a custom UI. Make sure to create a sampler within Input Configuration that corresponds with the string given in GetSampler.

Code: Select all

using UnityEngine;
using Naninovel;
using Naninovel.UI;

public class CallUIInput : CustomUI
{

private IInputManager inputManager;

protected override void Awake()
{
    base.Awake(); // make sure the required objects are assigned in the inspector
    inputManager = Engine.GetService<IInputManager>();

}

protected override void OnEnable()
{
    base.OnEnable();

    // Start listening for `ToggleInventory` input event to toggle UI's visibility.
    var toggleSampler = inputManager.GetSampler("ToggleSamplerUI");
    if (toggleSampler != null)
        toggleSampler.OnStart += ToggleVisibility;
}

protected override void OnDisable()
{
    base.OnDisable();

    // Stop listening for `ToggleInventory` input event.
    var toggleSampler = inputManager?.GetSampler("ToggleSamplerUI");
    if (toggleSampler != null)
        toggleSampler.OnStart -= ToggleVisibility;
}
}