Forum rules - please read before posting.

Scrolling through dialogue options with mouse wheel.

Is it possible to scroll through dialogue options with the mouse wheel? I am currently seeing if I can replicate Firewatches system where you still can walk around in first person but cycle through dialogue options with the mouse wheel. Is there anything native that does this, or will I need to do something custom. If so, any ideas how to script this would be greatly appreciated.

Cheers
Jacob

Comments

  • First of all, have your Conversation menu rendered with Unity UI.

    If your Input method is set to Keyboard Or Controller, you can then use the Engine: Manage systems Action to enable/disable direct-controlled menus when the Conversation menu is turned on and off. To configure which element is selected first, set it in the Conversation menu's properties.

    A mouse-wheel mapped to the Vertical input should do that - or an EventSystem that responds to a Unity input mapped to the default "Mouse Scrollwheel" input. A custom EventSystem prefab can be assigned in the Menu Manager.

    That should handle scrolling through the visible options. If you want to allow for "scrolling through" more options than are displayed on-screen, then you'll need to do a bit of custom scripting. First make "dummy" buttons that are invisible - one above and one below the visible options. Then configure your UI Buttons' Navigation panels so that scrolling "up" from the first dialogue option selects the "upper" invisible option, and vice-versa.

    Next you take your "dummy" buttons do the reverse - so that when you navigate e.g. "down" from the "top" dummy button, you select the first visible option. A custom script that hooks into OnSelect (see Unity's ISelectHandler documentation) can then automatically select the button it navigates to, as well as offset the AC DialogList element:

    AC.MenuDialogList dialogList = AC.PlayerMenus.GetElementWithName ("Conversation", "DialogList") as AC.MenuDialogList;
    dialogList.Shift (AC_ShiftInventory.ShiftNext, 1);
    
  • Hello

    I am trying to use the mouse wheel to navigate through dialog lists(up-down) and inventory (left-right).

    After spending almost a days with no result, I've updated AC in the hope it's native UI was added support for the mouse wheel... But no luck :smiley:

    So, I would like to ask a few questions about your workflow described above.

    At this point, for the dialog list, I have created an Unity UI, with 4 slots, and navigation arrows (up-down). I have attached the UI to AC and it is working correctly.

    Next I am stuck. I tried to add a component to the Event System ('Input axis scrollbar' or 'Optional mouse input module') but it doesn't work.

    I have already the two navigation buttons visible; should I attach the OnSelect handler to them?
    I was also thinking of another way: while the cursor stays on the dialog list, to catch inputs and if mouse scroll is detected somehow to send a click to the up/down button (shift next/previous). But I don't have any idea how to implement that.
    Could I somehow use the Scroll Rect script?

    I would like to keep this as simple as possible, preferably using the AC UI if possible.

    Thank you
    HD

  • Forgot to mention: Unity 2018.3.5f1, AC 1.70.4

  • My post above essentially breaks down the problem into two parts:

    1. Scrolling through the 4 visible slots with the mouse wheel
    2. Shifting which dialogue options the slots represent with the "shift" buttons

    What exact behaviour are you getting right now, exactly? Before 2., you'll need 1. to be working correctly.

    For 1., you'll need to first get direct-navigation of the menu working. Make sure that you've defined which element to select in your Menu's properties, and that the global Directly-navigate Menus during Conversations? setting is checked at the top.

    Without a custom EventSystem, you should now be able to scroll through the 4 visible slots with the arrow keys (or whatever is currently mapped to Vertical). If not, check the "Navigation" settings of your UI Button components.

    Next, you can create a custom EventSystem. "Input Axis Scrollbar" is not an AC component, so I don't know what you're referring to, there. However, a new empty GameObject with Optional Mouse Input Module should be all you need - just be sure to set the "Vertical Axis" to "Mouse ScrollWheel" (and that such an input is defined in your Input Manager and mapped to the mouse's 3rd axis).

    Make it a prefab, assign it in the Menu Manager, and that should be it for 1.

    For 2., here's a slightly different method: Create your navigation buttons and map them to AC to behave like regular shift left/right buttons (so that clicking on these shifts the dialogue list). Then attach the following to both of these Button GameObjects:

    https://paste.ofcode.org/rzBpUW6Pyzpt4WTQssJ9Fp

    Configure the "Scroll Direction" in the Inspectors, and this should then cause the button to be clicked when selected (to shift the list) and then select the top/bottom of the list again.

  • edited March 11

    Thank you for the detailed explanation. However I still have some issues.

    The issues come from the first part.

    I can navigate the 4 slots with my keyboard and also with hovering the mouse. If I want to select an option, I just press the mouse button. The shiftup/shiftdown works correctly.

    However, after I attach the custom EventSystem, I can use the scroll wheel to navigate, but I cannot select any option by pressing the mouse button, nor can I navigate with hovering the mouse on the list. It's like the mouse it's disabled except for the scroll wheel. I can't even select the shiftup/shiftdown buttons.

    At this point, the 2nd part (with the script) it is not working either.

    Thank you

    PS. The custom EventSystem has only the 'Optional Mouse Input Module' with the 'Vertical axis' set to 'Mouse Scrollwheel'

  • Putting aside the mouse for the moment: are you able to shift through the options using the scrollwheel.

    I'm perhaps forgetting myself. The "Optional Mouse Input Module" is a custom module that forces a menu to be either controlled by the mouse, or directly - not both at the same time.

    Try instead a regular Standalong Input Modue, with the same field value for "Vertical Axis".

  • I managed to make it work by using the 'Standalone Input Module', but now the script you attached throws in an error.

    So basically, if the 1st option is selected, and you scroll up, the UP button function is called, but throws in an error :

    NullReferenceException: Object reference not set to an instance of an object
    NoirGame.ScrollButton+d__6.MoveNext () (at Assets/MyScripts/ScrollButton.cs:62)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)

    Same happens if you scroll down through all the 4 slots and you reach the DOWN button.
    The correct lines for the errors are 61 and 65 (I've inserted a debug.log line at some point, thus the error on ScrollButton.cs:62)

    However, now I can understand what the OP of this post was trying to achieve, but what I am trying to do is just to use the scroll wheel as Windows Explorer does:

    • if the player is in a conversation with more options than can fit in the dialog box, he scrolls down and the list is moved down. When he reaches the end, the 'Down' arrow dissapears but the 'Up' arrow remains.
    • if the player is in his inventory and he scrolls down, the inventory list moves to the right.

    Basically I would like to map mouse scroll down/up directly to the ShiftUp/Down buttons. An example of what I am trying to do is in the latest Leisure Suit Larry game.

    Sorry if I mislead you, but I was trying not to start a new topic just to keep the forum clean.

    Thank you

  • Thanks for the clarificaton, but that's already what I understood your intended behaviour to be.

    I will need to be clear on the current state of things, though. Aside the scroll buttons, does mousewheel scrolling work for the options that are displayed?

    It sounds like the issue is just that the script has the directions the wrong way around. Try setting the "UP" button's Scroll Direction field to Down, and the "Down" button's to Up.

    These fields don't refer to the way that the options are shifted - just the direction for the UI handler to automatically navigate along. The idea is that when the button is highlighted, it clicks itself, and then forces the option just below it to become highlighted again.

  • First I want to thank you for taking your time to help me. I just hope I am not making any noob mistakes here.

    I managed to make this thing work from one point of view, however there are a lot of issues.

    I will attach some pictures to be more clearly

    This first example uses both the ShiftUp/Down buttons. I must tell you that if I click on them they behave correctly. Also, I tried using 2 identical scripts (scroollbutton and scrollbutton2) just to see if I get different results. But it behaves the same as with the same script

    https://ibb.co/Fzn6G7F
    *sorry for not editing the pic a bit :)

    As a test, I removed the ShiftUp button both from the Unity prefab and AC, and I get a different effect when scrolling down. This time the DialogueList always keeps its focus, but when I reach the last visible option, it uses the ShiftDown and then the selected option is the new top one (so you have to scroll again through the visible list, then you shift the list down, then again you have to scroll)

    I am thinking of creating a new project just with this and send it to you.

    Thank you

  • I am thinking of creating a new project just with this and send it to you.

    I think that would be best. It wouldn't need either of the AC Demo folders, or any custom characters / models, just a test scene / Conversation that demonstrates the issue. If you PM it to me, I'll take a look.

  • Actually, I think I have another script for this - let me dig it up and see if I can make a generic version.

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.