Reputation: 1549
I updated to MRTK v2.1 and right now I'm struggling with the toggles from my previous post. Don't get me wrong, the issue in the linked post got fixed! But now I'm having a different problem.
What happens:
I have a settings panel in my scene and the component DebugContent.cs
attached to it. Every time I open it, OnEnable
triggers and sets the state of my toggles according to third parameter of SetToggleState()
. So lets say that the third parameter is always true → DiagnosticsSystem.ShowProfiler
, debugProvider.enabled
and speechInputHandler.enabled
are true!
On MRTK v2.0 I had no issues, but now on v2.1 my toggles are not getting toggled by the first time. I have to open my panel a second time so the toggles are toggled!
//OnEnable in DebugContent.cs
private void OnEnable()
{
// Set Profiler, Log viewer, Speech Input
Utils.SetToggleState(profilerTgl, profilerTxt, DiagnosticsSystem.ShowProfiler);
Utils.SetToggleState(logViewerTgl, logViewTxt, debugProvider.enabled);
Utils.SetToggleState(speechInputTgl, speechInputTxt, speechInputHandler.enabled);
}
//SetToggleState in Utils.cs
public static void SetToggleState(Interactable comp, TextMesh tm, bool isOn)
{
Debug.Log("Util >> SetToggleState >> Set toggle → " + comp.gameObject.name +" to → " + isOn + " >> Comp is enable → " + comp.enabled + " and has dimension → " + comp.CurrentDimension);
if (isOn)
{
comp.CurrentDimension = 1;
tm.text = "On";
}
else
{
comp.CurrentDimension = 0;
tm.text = "Off";
}
Debug.Log("Util >> SetToggleState >> Toggle set to dimension → " + comp.CurrentDimension);
}
More on:
The strange part is that the first time I open my panel the text of my toggles shows On
but my toggle is not toggled. Only if I open my panel the second time the toggle get toggled:
The output of my Debug.Log
is also interesting, because the current dimension is every time 0:
First time:
Util >> SetToggleState >> Set toggle → Debug_Tgl to → True >> Comp is enabled → True and has dimension → 0
Util >> SetToggleState >> Toggle set to dimension → 1
Second time:
Util >> SetToggleState >> Set toggle → Debug_Tgl to → True >> Comp is enabled → True and has dimension → 0
Util >> SetToggleState >> Toggle set to dimension → 1
I'm using CurrentDimension
, because SetDimensionIndex
is now deprecated.
I created a bug report on github.
Upvotes: 0
Views: 102
Reputation: 36
Please see response on the github page. As a workaround, call the Utils.SetToggleState
in both OnEnable
and Start. DebugContent
OnEnable is invoked before Interactable.Awake
which make the problematic
Upvotes: 1