Issue 1: OnToggleValueChanged() event handling code generates a call to CastTo<> which does not exist in the class or the GeneratedComponent base class.
Compiler error: CS0103 The name 'CastTo' does not exist in the current context
Generated Code: CastTo().toggleText.color = toggleColorOn;
Issue 2: Start() entry generates superfluous assignment of the toggleText variable when setting the color at the start; this generates a warning.
Compiler warning: CS1717 Assignment made to same variable; did you mean to assign something else?
GeneratedCode: toggleText = toggleText;
Steps to Reproduce:
- Start with a fresh UI Canvas in a scene, add UI > Toggle in the Hierarchy
- Select the Toggle, in the Inspector use Add Component > Bolt > Class Component
- Save, then select the class, add the following in the Inspector:
- New Graph, type "New Flow Behavior" named "ToggleBehavior"
- Three new Variables:
ToggleColorOn (type UnityEngine.Color) - Green Color
ToggleColorOff (type UnityEngine.Color) - Red Color
ToggleText (type UnityEngine.UI.Text)
- Edit the Flow Behavior so it looks like the attached image:
Behavior Description: On startup, I want to find the label for the toggle and store its Text component in a variable. Since I have its initial value set to false, I also set the initial text color. When the user checks and un-checks the Toggle, I want to set the text color of the toggle to green if it is checked and red if it is unchecked.
Note: There is also the issue with the generation of 'Register' and 'Unregister' calls on the EventBus, but this has been reported in a separate post.
Customer support service by UserEcho