Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by AlbertoVgdd · May 01, 2021 at 06:05 PM · uiinputmultiplayercanvasdevices

How can multiple users control a single UI canvas using InputSystem?

Hi, I am working on a local co-op game where each user uses a different device and controls a different character. The game does not feature split-screen and only makes use of a single UI canvas, which each user should be able to control.


The issue:

When the game is launched, the scene only contains the main menu and it can be used by any device. From there, users are able to join and select a device to use. When the game starts, different PlayerInput are spawned for each user + device combo.


At this point each device controls its corresponding character just fine, but once the "Pause Menu" is displayed (and the InputActionMaps are switched) only one of the users is able to use the UI.


My current configuration:

  • I have a PlayerInputActions named MyActions with two maps: Gameplay, Menu

  • Each character prefab contains a PlayerInput that uses MyActions

  • The UI has a EventSystem and InputSystemUIInputModule that uses MyActions/Menu


What I have already tried:

  • Replace the UI EventSystem for a MultiplayerEventSystem, didn't work

  • Replace the UI EventSystem for a MultiplayerEventSystem and add new MultiplayerEventSystem and InputSystemUIInputModule to each character that spawns, didn't work

  • All of the above plus pointing the PlayerRoot field of each MultiplayerEventSystem to the UI and pointing the UI Module field of each PlayerInput to its corresponding module, didn't work

  • Exactly the same but pointing the UI Module field of each PlayerInput to the module on the UI, didn't work




I ran out of ideas already, I can not find any help in either the docs or the forums. Has anyone faced a similar issue? Could you please explain to me how to use these event systems and ui modules to accept inputs from different users?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by AlbertoVgdd · May 07, 2021 at 09:10 AM

I figured it out. I will post the solution here for anyone trying to achieve the same behavior. Basically, what needs to be in the scene is:

  • The different player characters, each with a PlayerInput.

  • A single UI Canvas with Event System and Input System UI Input Module.

  • A single InputActionAsset with 2 actions maps (Gameplay and Menu)

    What needs to happen when the game is paused:

1- Deactivate the inputs of all the characters except the one who paused the game using PlayerInput.Deactivate()

2- Use PlayerInput.SwitchCurrentActionMap("Menu") on the character who paused the game.

3- Assign the action map instance of the player who paused to the Input Sytem UI Input Module using: InputSystemUiInputModule.ActionsAsset = PlayerInput.actions

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Pangamini · Oct 13, 2021 at 09:17 PM 0
Share

Do you think it's possible to have multiple players control the UI at the same time? Not just the one that paused the game? I am trying to make the UI controllable by all players at all times

avatar image
0

Answer by GetLitGames · May 01, 2021 at 06:50 PM

https://docs.unity3d.com/Packages/com.unity.inputsystem@0.9/manual/UISupport.html?_ga=2.120387531.239237062.1619894930-120019661.1587610245

I found this from a forum thread: https://forum.unity.com/threads/request-tutorial-or-guide-on-how-to-use-the-new-multiplayer-event-system.736787/

Also, here is a recent video: https://www.youtube.com/watch?v=81GecyuNapg

Also another video tutorial on creating local multiplayer intput: https://www.youtube.com/watch?v=_5pOiYHJgl0

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AlbertoVgdd · May 01, 2021 at 07:01 PM 0
Share

Thanks for the quick response. Unfortunately, I have already visited all of these resources before. None of them apply to what I want to achieve, as all of them explain how to setup a scene with multiple UI canvas, while I want to just use 1 UI canvas.

avatar image GetLitGames AlbertoVgdd · May 01, 2021 at 07:23 PM 0
Share

Use one Canvas and all the supporting UI. Have a script on either the Canvas or another script high in the hierarchy that has a PlayerNumber property that can be changed to be 1,2,3,4 etc. Create a prefab from the Canvas then duplicate it in the hierarchy and set the PlayerNumber to be different for each Canvas. All your button clicks that go to functions can have some code to lookup their PlayerNumber from the top level script (simply GetComponentInParent) if needed to know which player is using the buttons etc. Basically it sounds like maybe you are trying to work around a technical detail that doesn't need to be worked around - there is no reason why you can't use multiple Canvas if that's what the system requires. Simply use the Prefab system to have multiple Canvas but are from the same prefab so are not really separate Canvas.

avatar image AlbertoVgdd GetLitGames · May 01, 2021 at 07:45 PM 0
Share

But that would imply having multiple canvas, which is precisely what I am trying to avoid at the moment.

Show more comments
avatar image
0

Answer by luizguilherme0856 · Mar 23 at 03:10 PM

If anyone still have this problem, I solved it by simply making the button interaction from scratch. When the game is paused and the player press the arrows on the keyboard or the gamepad, it call a method that change the current selected button from the event system. And then you just need another method that clicks the current selected button.

I know its a mess but it works and you don't need to use multiple canvas. Also @Pangamini both players can control the screen at the same time.

  public void SelectButton(bool goUp)
 {
         var buttonSelected = eventSystem.currentSelectedGameObject.name;
 
         if(buttonSelected == "Resume button")
         {
             if (goUp)
             {
                  eventSystem.SetSelectedGameObject(quitButton);
             }
             else
             {
                 eventSystem.SetSelectedGameObject(mainMenuButton);
             }
 
         }
         else if (buttonSelected == "Main menu button")
         {
             if (goUp)
             {
                  eventSystem.SetSelectedGameObject(resumeGameButton);
 
             }
             else
             {
                 eventSystem.SetSelectedGameObject(quitButton);
             }
 
         }
         else if( buttonSelected == "Quit game button")
         {
             if (goUp)
             {
                 eventSystem.SetSelectedGameObject(mainMenuButton);
             }
             else
             {
                 eventSystem.SetSelectedGameObject(quitButton);
             }
 
         }
         else { Debug.LogError("Button not found."); }
     }







Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

340 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Control UI Input Field entirely with code? 1 Answer

Block Input.GetMouseButtonDown() when clicking on UI element 2 Answers

Detect which prefab triggers the button UI 1 Answer

Unity 5.2 - How can I keep other players from using a menu? 0 Answers

BaseInputModule and custom navigation 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges