Forum rules - please read before posting.

Selecting Dialogue Options with Direct Menu Navigation

Hey!

I am re-visiting having first person look activated during conversations, and want to directly navigate conversations.

In the past I asked if I could use the mouse wheel to navigate, and that advice worked great back then!

Now at the moment, when clicking the left or mouse button, it un selects the dialogue option. As you can see in this video

https://drive.google.com/file/d/1JnWDaz9pL4zRGL4TIlctGML4vwLRvxoU/view?usp=sharing

Whats causing it to un select it? Is there a way I can disable this?

Checking inputs mouse 0 is set to 'fire 1' and also 'submit' (which I think activated the dialogue option)

Seems like fire 1 is causing it to de select maybe?

In an ideal world I'd love left click to actually trigger the dialogue option too.

Comments

  • In the past I asked if I could use the mouse wheel to navigate, and that advice worked great back then!

    I'm not sure how far back that was, but AC now has a Mousewheel Scrolling UI component that you can attach to your Canvas prefab to have it support mousewheel-scrolling.

    Now at the moment, when clicking the left or mouse button, it un selects the dialogue option. As you can see in this video

    This is a Unity UI menu? You'll need to have the menu be directly-controlled - otherwise a mouse-click will cause Unity UI to react to the mouse's location, as opposed to what element is selected.

    Do you have Directly-navigate Menus during Conversations? checked in the Menu Manager? Are you relying on AC's own EventSystem or a custom one?

  • edited August 2020

    Yep I have the Directly- Navigate Menus during conversations checked. I am also using Unity UI but I am using AC's event system for selecting dialogue options, see here
    https://i.imgur.com/vpmpK2N.png

  • View your EventSystem's Inspector at runtime. At the bottom, it should list the currently-selected GameObject. What happens when the dialogue options become unselected?

    Does this issue occur if you have the Menu pause the game, and check Directly-navigate Menus when paused? checked?

  • In the event system, item is selected, but when I mouse click, it just makes it blank.

    In the pause menu, it works! And I am able to select with mouse click too.

  • Do you have Allow regular gameplay during Conversations? checked in the Settings Manager? If so, does it behave if you temporarily uncheck it?

    If so, you may need to force direct-control over gameplay menus using the Engine: Manage systems Action as part of the Conversation menu's "ActionList when turn on" field.

    Otherwise, what if you rely on an AC menu, not Unity UI?

  • Unfortunately I tried that already, and checking or unchecking that option does nothing.

    Also tried changing to direct control, among the other options.

    Just checked AC menu, it works! So I guess it's some problem with how it communicates with the Unity UI prefab

    Unfortunately we spent quite a bit of time to get a robust Unity UI menu to work visually how we want over multiple set ups, so I'd rather not move on over back to AC menu

    I will continue to trouble shoot to see if there is maybe something else thats causing it in the prefab. If you have any other ideas as to whats triggering it, or a way I could debug it, that would be greatly appreciated, thanks for your help so far.

  • Oh wow haha, so this is actually a unity problem that a lot of developers are requesting Unity to fix/implement a better work around.

    So unity on default when using UI will deselect when clicking outside the button. There a bunch of work arounds for this, some ore complicated than others, but so far the one at the end of the thread is the easiest/quickest

    https://forum.unity.com/threads/feature-request-option-to-disable-deselect-in-ui-input-module.761531/

    By editing the eventsystem.cs on line 150 you can add

    if (selected == null) return;
    

    And this will fix this issue for anyone reading this in the future. However this could cause issues? who knows, the user in the forum has reported none so far. I will reply to this thread if it causes me issues.

    As always thanks for your help Chris!

  • OK spoke to soon, This fixes it, but unfortunately by keeping it selected, it no longer triggers the highlight when new conversation comes up, but selection still works.

    Will keep trouble shooting!

  • So I was able to trigger the highlight animation via a script

    public class HighlightThisObject : MonoBehaviour
    {
    public Animator dialogueOption;

    void OnEnable()
    {
      dialogueOption.SetTrigger("Highlighted");
      print("highlight triggered");  
    }
    

    However for it to work, I had to enable it via the "On' animation of the dialogue options transition in.

    Seems a bit messy, but it works. The script triggers when the conversation UI is enabled, but there is something that is triggering "normal" to the animator after the trigger "highlighted" is sent (even though it is selected in the event manager)

    Chris, what is triggering in AC that is sending the animation triggers to the auto select in the menu, so maybe I can look into making something more robust?

    Also for anyone who finds this useful, I wrote a script to listen when conversation is activated, but unfortunately using "Public Animator" doesn't work for my problem since its instantiated in the scene and loses its connection.

    public class TriggerConversationHighlight : MonoBehaviour
    {

    public Animator dialogueOption;
    
    void Start ()
    {
        print("highlightstart");
    }
    
     private void OnEnable ()
    {
        EventManager.OnStartConversation += StartConversation;
    }
    
    private void OnDisable ()
    {
        EventManager.OnStartConversation -= StartConversation;
    }
    
    void StartConversation (Conversation conversation)
    {
        dialogueOption.SetTrigger("Highlighted");
        print("highlighted");
    }
    

    }

    Another question Chris, I tried to figure out how to attach an animator via searching a constant ID in script, but I couldn't figure it out. Could you please write an example if you have time.

    Ideal world would be something that works like

    public Animator dialogueOption;

    but attaches the constant ID in the inspector.

    otherwise something that I can attached to a variable via writing the constant ID manually in script.

    Again thanks for your time, I know I am still quite fresh with scripting.

  • edited August 2020

    So unity on default when using UI will deselect when clicking outside the button.

    This is what AC actually tries to resolve itself by its own OptionalMouseInputModule script, which replaces the default EventSystem unless you assign an override in the Menu Manager. I haven't been able to recreate your issue, but you can see the script at work by the fact that it doesn't occur when the game is paused.

    what is triggering in AC that is sending the animation triggers to the auto select in the menu, so maybe I can look into making something more robust?

    You can force the selection of UI GameObjects with:

    AC.KickStarter.playerMenus.SelectUIElement (gameObjectToSelect);
    

    Also for anyone who finds this useful, I wrote a script to listen when conversation is activated, but unfortunately using "Public Animator" doesn't work for my problem since its instantiated in the scene and loses its connection.

    You can attach a script to the option itself in the prefab - since OnEnable will be called whenever a conversation begins and the menu turns on.

    I tried to figure out how to attach an animator via searching a constant ID in script, but I couldn't figure it out. Could you please write an example if you have time.

    Though you shouldn't have to (see above), you can call ConstantID.GetComponent to convert an ID number into a Unity Object. The equivalent code would be:

    public int dialogueOptionID;
    
    private void OnEnable () { EventManager.OnStartConversation += StartConversation; }
    private void OnDisable () { EventManager.OnStartConversation -= StartConversation; }
    
    void StartConversation (Conversation conversation)
    {
        Animator dialogueOption = ConstantID.GetComponent <Animator> (dialogueOptionID);
        dialogueOption.SetTrigger("Highlighted");
    }
    

    Being able to assign an Animator and display its ID involves custom editor scripts, and is a lot more involved.

  • Hey Chris,

    Thanks for the extra stuff, esp the constant ID stuff, don't need to use it for this, but I think it will come in handy.

    OK interesting you mention the optional input module stuff, I manually attached myself to the event manager and it, solved all the problems

    Then I realised that my co developer put an event system into the scene, so AC was not instantiating an event system with the correct optional input module. Everything works as it should.

    Thank you for all the troubleshooting help, its at least taught me a lot more about code haha

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.