fix(MultipleMatches): MatchGUI Toggle OnValueChanged > OnToggleClicked

This commit is contained in:
MrGadget1024 2024-01-01 07:53:00 -05:00
parent 56a1aa096f
commit e1195391c6
2 changed files with 17 additions and 6 deletions

View File

@ -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:

View File

@ -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<CanvasController>();
#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]