0

2.0.0a8 C# Code Generation: Missing method call CastTo<> and superfluous assignment warning

jfalcon 7 months ago updated 7 months ago 0

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:

  1. Start with a fresh UI Canvas in a scene, add UI > Toggle in the Hierarchy
  2. Select the Toggle, in the Inspector use Add Component > Bolt > Class Component
  3. Save, then select the class, add the following in the Inspector:
    1. New Graph, type "New Flow Behavior" named "ToggleBehavior"
    2. Three new Variables:
      ToggleColorOn (type UnityEngine.Color) - Green Color
      ToggleColorOff (type UnityEngine.Color) - Red Color
      ToggleText (type UnityEngine.UI.Text)
  4. 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.

Bolt Version:
2.0.0a8
Unity Version:
2019.2.19f1
Platform(s):
PC
Scripting Backend:
Mono
.NET Version (API Compatibility Level):
.NET 4.x
Bolt 2