From e1195391c6d2b9525e37b843b78f64977154b1de Mon Sep 17 00:00:00 2001 From: MrGadget1024 <9826063+MrGadget1024@users.noreply.github.com> Date: Mon, 1 Jan 2024 07:53:00 -0500 Subject: [PATCH] fix(MultipleMatches): MatchGUI Toggle OnValueChanged > OnToggleClicked --- .../MultipleMatches/Prefabs/MatchGUI.prefab | 14 +++++++++++++- .../Examples/MultipleMatches/Scripts/MatchGUI.cs | 9 ++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Assets/Mirror/Examples/MultipleMatches/Prefabs/MatchGUI.prefab b/Assets/Mirror/Examples/MultipleMatches/Prefabs/MatchGUI.prefab index bb96954d2..ef84e0f1e 100644 --- a/Assets/Mirror/Examples/MultipleMatches/Prefabs/MatchGUI.prefab +++ b/Assets/Mirror/Examples/MultipleMatches/Prefabs/MatchGUI.prefab @@ -206,7 +206,19 @@ MonoBehaviour: m_Group: {fileID: 0} onValueChanged: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 114572912279416540} + m_TargetAssemblyTypeName: Mirror.Examples.MultipleMatch.MatchGUI, Mirror.Examples + m_MethodName: OnToggleClicked + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 m_IsOn: 0 --- !u!114 &114572912279416540 MonoBehaviour: diff --git a/Assets/Mirror/Examples/MultipleMatches/Scripts/MatchGUI.cs b/Assets/Mirror/Examples/MultipleMatches/Scripts/MatchGUI.cs index 74c0b1c85..f378ca535 100644 --- a/Assets/Mirror/Examples/MultipleMatches/Scripts/MatchGUI.cs +++ b/Assets/Mirror/Examples/MultipleMatches/Scripts/MatchGUI.cs @@ -1,4 +1,4 @@ -using System; +using System; using UnityEngine; using UnityEngine.UI; @@ -25,14 +25,13 @@ public void Awake() // Deprecated in Unity 2023.1 canvasController = GameObject.FindObjectOfType(); #endif - toggleButton.onValueChanged.AddListener(delegate { OnToggleClicked(); }); } [ClientCallback] - public void OnToggleClicked() + public void OnToggleClicked(bool isOn) { - canvasController.SelectMatch(toggleButton.isOn ? matchId : Guid.Empty); - image.color = toggleButton.isOn ? new Color(0f, 1f, 0f, 0.5f) : new Color(1f, 1f, 1f, 0.2f); + canvasController.SelectMatch(isOn ? matchId : Guid.Empty); + image.color = isOn ? new Color(0f, 1f, 0f, 0.5f) : new Color(1f, 1f, 1f, 0.2f); } [ClientCallback]