Skip to content

Calling ToolbarControl.SetFalse when the stock button has not been created will call the onTrue callbacks #22

@JonnyOThan

Description

@JonnyOThan
	public void SetFalse()
	{
		if (stockButton != null)
		{
			stockButton.SetFalse();
		}
		else
		{
			ToggleButtonActive();
		}

		UpdateToolbarIcon();
	}

I have an event handler on level loaded:

 	Void TUFX.TexturesUnlimitedFXLoader:configGuiEnable ()+0x0 at C:\Users\Jon\source\repos\TUFX\Plugin\TUFX\Addon\TexturesUnlimitedFXLoader.cs:[600:13-600:35]	C#
>	Void ToolbarControl_NS.ToolbarControl:SetButtonActive ()+0x18 at /var/lib/jenkins/workspace/T-Z/ToolbarControl/ToolbarControl/ToolbarControl.cs:845	C#
 	Void ToolbarControl_NS.ToolbarControl:ToggleButtonActive ()+0x1b at /var/lib/jenkins/workspace/T-Z/ToolbarControl/ToolbarControl/ToolbarControl.cs:863	C#
 	Void ToolbarControl_NS.ToolbarControl:SetFalse ()+0x23 at /var/lib/jenkins/workspace/T-Z/ToolbarControl/ToolbarControl/ToolbarControl.cs:429	C#
 	Void TUFX.TexturesUnlimitedFXLoader:CloseConfigGui ()+0x6 at C:\Users\Jon\source\repos\TUFX\Plugin\TUFX\Addon\TexturesUnlimitedFXLoader.cs:[620:13-620:43]	C#
 	Void TUFX.TexturesUnlimitedFXLoader:onLevelLoaded (GameScenes)+0x22 at C:\Users\Jon\source\repos\TUFX\Plugin\TUFX\Addon\TexturesUnlimitedFXLoader.cs:[418:13-418:30]	C#
 	Void EventData`1:Fire (GameScenes)+0xb8 at :-1	C#
 	Boolean <FireLoadedEvent>d__46:MoveNext ()+0x9d at :-1	C#
 	Void UnityEngine.SetupCoroutine:InvokeMoveNext (IEnumerator, IntPtr)+0x27 at :-1	C#

My code:

        internal void CloseConfigGui()
        {
            mainToolbarControl.SetFalse();
        }

In Start():
                mainToolbarControl = gameObject.AddComponent<ToolbarControl>();
				mainToolbarControl.AddToAllToolbars(
                    configGuiEnable,
                    configGuiDisable,
                    ApplicationLauncher.AppScenes.ALWAYS,
					toolbarMainName,
                    toolbarMainName,
                    "TUFX/Assets/TUFX-Icon1",
                    "TUFX/Assets/TUFX-Icon1",
                    toolbarMainName);

I would expect this to either always call the onFalse callback, or at least do nothing if the button state is already "false." But it calls the onTrue callback instead via ToggleButtonActive because SetFalse doesn't check the current state of the button.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions