How can i have 2 Event Systems in the scene so 2 players can select different UI buttons to choose their character? (like tekken for example). I had this solution in my game but in Unity 2017.3 it doesn’t work anymore and I don’t know why: http://blog.pastelstudios.com/2015/...ultiple-event-systems-single-scene-unity-5-1/
Create 2 empty objects and add this script and a Standalone Input Model on both: Code (csharp): using UnityEngine.EventSystems; using UnityEngine; public class MyEventSystem : EventSystem { protected override void OnEnable(){ base.OnEnable (); } protected override void Update(){ EventSystem originalCurrent = EventSystem.current; current = this; base.Update(); current = originalCurrent; } } Then add these two scripts on each button selecting one event systems: Code (csharp): using UnityEngine.EventSystems; using UnityEngine.UI; public class MyButton : Button { public EventSystem eventSystem; protected override void Awake() { base.Awake (); eventSystem = GetComponent<MyEventSystemProvider> ().eventSystem; } public override void OnPointerDown(PointerEventData eventData) { if (eventData.button != PointerEventData.InputButton.Left) return; // Selection tracking if (IsInteractable() && navigation.mode != Navigation.Mode.None) eventSystem.SetSelectedGameObject(gameObject, eventData); base.OnPointerDown(eventData); } public override void Select() { if (eventSystem.alreadySelecting) return; eventSystem.SetSelectedGameObject(gameObject); } } Code (csharp): using UnityEngine.EventSystems; using UnityEngine; using System.Collections; public class MyEventSystemProvider : MonoBehaviour { public EventSystem eventSystem; }
Hi there ! Have you managed to make it work ? :$ In my selection screen I haven't, but the screen was a bit more complex, there are dropdown and other stuff... Also I'm using InControl as an Input Manager, any suggestion ?
Hi, I know this is marked as [SOLVED] but I'm a little confused by the opening post: Did this work before version unity 2017.3 or is this a solution for multiple inputs in version 2017.3? I'm trying this out without success, so I'm not sure if it's on my end (like most of the time) or this just simply does not work anymore...
Up ! First, thank you for this solution, it works pretty much fine with the Unity built-in input manager. But when both of the event systems are selecting the same button, and then selecting an other one, both of the buttons selected are still selected by the event systems but one of the two is not highlighted anymore. Does anyone experienced this issue ? I didn't add any other scripts, only the ones mentioned above with classic buttons parented to a panel which has an horizontal layout group.