Splitscreen and Rewired

Hello there!

I have a question about setting up rewired and splitscreen. I thought that a great way to navigate inventory menus was if each player could use a cursor. Rewired can make this pretty easy. I followed the multiplayer inventory steps on the opsive website, and then tried to add this mouse functionality after. On each of the rewired event systems, you can create a 'Player Mouse'. You can actually tweak the allowable movement areas of each mouse so they can only move around their side of the screen. This works great and I can easily drag and drop items between inventories and item view slot containers. The problem is that when you have both player inventories up, then both players click on an item that has an item action menu the UI navigation sort of falls apart right after both players try to use it. There are some known limitations to the Rewired Player Mouse listed on the Rewired website, and I have done a bunch of looking through those scripts and the Event System Manager from Opsive but can't really tell where or how the functionality stops working. It looks like if Player 1 brings up an item action menu, it automatically deselects what Player 2 is hovering over and selects something on the Player 1 side and the Player 2 can't hover over anything on their canvas.

Would love to hear any thoughts on how this could work, or if this is a square peg/round hole situation.
 
I've never used the multiple mouse cursor with rewired. So I am not familiar with how it works.

You followed the steps exaclty as defined here correct?:

so each inventory UI should have it's own canvas, it's own DisplayPanelManager and it's own RewiredEventSystem.
For the cursors to work properly they must be setup to only interact with a single RewiredEventSystem, not both. Since I'm not familiar with this feature of rewired I cannot say whether it is possible or not.

I'd recommend you contact the Author of Rewired, he might be able to clarify whether this is possible or not.
Also feel free to send a video (use streamable.com) of your game showcasing how it breaks it may give me some idea of why it doesn't work... although to be frank It probably won't
 
Thanks for the response!

I did follow those steps initially. Once everything was properly working, I remembered that the Player Mouse feature existed with Rewired so I thought I would spend a bit of time to see if it could work. I totally understand that this falls outside of what was included when I got the Ultimate Inventory system so I don't expect it to work, but it's so close to working that I thought it was worth reaching out to see if anyone had some ideas.

Here is the general idea: https://streamable.com/qnri5l

You can see at around the 27 second mark, as soon as the action pop up window is shown on the left side, the right cursor is no longer highlighting buttons. My suspicion is that Player Mouse doesn't make use of the Event System Manager (understandably) and when a on click event is processed, it just tells all event systems to select it. And at that point the 2nd event system is now somehow using the 1st players cursor events.

If I do find any ways to work around this I'll be sure to post my findings.

Thanks so much for any help!
 
Thanks for the information, I think I might have an idea of why it is not working.
Just as you said the button click sets the selected gameobject in the EventSystem... But it doesn't know which one, so it probably sets it on both or just the first one it finds.

In the ActionButton class try replacing this function:
Code:
/// <summary>
/// Handle the pointer down event.
/// </summary>
/// <param name="eventData">The event data.</param>
public override void OnPointerDown(PointerEventData eventData)
{
    OnPointerDownE?.Invoke(eventData);
    if (eventData.button != PointerEventData.InputButton.Left)
        return;
    /*
     * Since the base function uses private variables I do some trickery to select the eventsystem the UIS way.
     *
     */
    
    // Selection tracking
    var eventSystem = EventSystemManager.GetEvenSystemFor(gameObject);
    if (IsInteractable() && navigation.mode != Navigation.Mode.None && eventSystem != null) {
        eventSystem.SetSelectedGameObject(gameObject, eventData);
    }
    
    // Prevent the base class from selecting the gameobject with any event system.
    var navigationTemp = navigation;
    navigation = new Navigation(){mode = Navigation.Mode.None};
    base.OnPointerDown(eventData);
    navigation = navigationTemp;
}

My assumption is that those cursors use the OnPointerDown event, which by default use the base Selectable class implementation of that function which does not use my solution for using multiple eventsystems.

If that's the case you'll most likely need to use Action Butons (or your own custom buttons), instead of basic Unity Buttons for your game. Let me know if that change works, I'll add it in the next update
 
So good news and bad news. That script didn't solve the problem, but it led me down a rabbit hole of debugging. The answer was actually incredibly easy and had nothing to do with code. There is a game object in the default Item Action Panel called "On Click Close Transparent Background". The rect transform of this object took up both players screens and they ended up conflicting with each other. Once I resized it to fit the clickable area per player it all works great.

I'm going to keep going forward with this style of UI control, and if I run into any more issues I'll be sure to let you know! As it looks right now it could be a pretty great option for others to use too.

Thanks again for helping out! Very excited to continue on!
 
Top