Capixo Posted January 26 Posted January 26 Hello Unigine Community, I'm working on a component in Unigine 2.20 and I've run into an issue with the PROP_PARAM(Switch, ...) property type that's making the editor experience a bit unintuitive. Problem Description: In my component's header file, I have declared a simple boolean switch like this: cpp PROP_PARAM(Switch, useBackgroundImage, true, "Enable Background Image"); My expectation, based on standard engine behavior, is that this would render as a checkbox in the Properties panel, allowing me to simply check or uncheck it to toggle a boolean value. However, in the Unigine 2.20 editor, this property is rendered as a dropdown menu. The problem is that this dropdown menu only contains a single option, which is the display name of the property itself ("Enable Background Image"). There is no "false" or "unchecked" state visible in the UI. This makes it very difficult to visually confirm the state of the boolean. I can't tell at a glance whether the switch is on or off, as the dropdown always appears the same. While the underlying logic might be working correctly (I can verify it with console logs), the lack of a clear, interactive UI element is a significant hurdle for workflow. What I'm Looking For: I would like to know if this is the intended behavior for PROP_PARAM(Switch, ...) in Unigine 2.20, or if there might be a configuration issue on my end. More importantly, is there a way to define a property that renders as a standard checkbox in the editor? A simple, clear checkbox for boolean values is a fundamental part of an intuitive user interface, and I'm hoping there's a standard way to achieve this. I've already tried workarounds, like using an Int property with 0/1 values, but it's not as clean or intuitive as a native checkbox. Any insights or suggestions would be greatly appreciated! Thank you!
Amerio.Stephane Posted January 26 Posted January 26 Hello, Switch is intended to hold an ENUMERATION, not a Boolean, hence the combobox in the UI. enum SourceType { NODE_ENABLE, SURFACE_EMISSION, MATERIAL_EMISSION, }; PROP_PARAM(Switch, source_type, 0, "Node Switch,Emissive Surface,Emissive Material"); What you are looking for is Toggle: PROP_PARAM(Toggle, switch_node_enable, 0); // for "Surface Emission" type enable/disable object with emission 1
Capixo Posted January 27 Author Posted January 27 13 hours ago, Amerio.Stephane said: Hello, Switch is intended to hold an ENUMERATION, not a Boolean, hence the combobox in the UI. enum SourceType { NODE_ENABLE, SURFACE_EMISSION, MATERIAL_EMISSION, }; PROP_PARAM(Switch, source_type, 0, "Node Switch,Emissive Surface,Emissive Material"); What you are looking for is Toggle: PROP_PARAM(Toggle, switch_node_enable, 0); // for "Surface Emission" type enable/disable object with emission That's it! A perfect and crystal-clear answer. Thank you so much! I had completely misunderstood the intended use of Switch vs. Toggle. I always assumed Switch was the go-to for boolean values, but your explanation that it's for enumerations makes perfect sense. Changing PROP_PARAM(Switch, ...) to PROP_PARAM(Toggle, ...) in my header file immediately fixed the issue. I now have the checkbox I was looking for, and my property panel is finally intuitive. This is a huge help and clears up a lot of confusion. I really appreciate you taking the time to explain the distinction! Thanks again!
Capixo Posted January 27 Author Posted January 27 One tip for newbie like me: If you want to use PROP_PARAM(Switch, ...) to archive the boolean effect, using two enumerations equals the PROP_PARAM(Toggle, ...).
Recommended Posts