What should I use to active one of many UI elements

Issue #40 resolved
ZhaoXiangXML created an issue

I've 5 images in my canvas, and an Enum property in my context. I'd like to active one of the images by the Enum value. Is Switch what I need? Or should I set 5 ActiveSetters on each of the images?

Another case is like I've 5 Toggles in a ToggleGroup, and an Enum property in my context. I'd like to turn one of the Toggles on when the Enum value changed in code, and change the property value when user clicked one of the toggles. For now I use 5 ActiveSetters and 5 EquilChecks for the Setter part, and use 5 custom Commands for the change part.

Comments (7)

  1. Christian Oeing repo owner

    Yes, right now I work with the EqualityCheck way as well. Like in the EnumEqualityCheck example.

    A switch would be an option to provide a data value based on the enum value. But the case you describe (disable the non-selected elements) would be a little bit different as a use case. I will keep the issue open and see if I can add another script for the next version to handle this case.

  2. Christian Oeing repo owner

    Add a GroupActiveSetter (base class) and a EnumGroupActiveSetter to activate/deactivate a group of game objects

    An example is included which uses the same setup as the EnumEqualityCheck example to show how the EnumGroupActiveSetter can make it easier to handle multiple enum <-> game object mappings

  3. Log in to comment