I have been trying to find something to this for so long and cant find an answer.
what i want to to is setup a Ui slider using INT from 1 - 10
when slider is at 1 object 1 is enabled. when slider is at 2 or 5. objects 1 2 3 4 5 is enabled
basically assign an object to a number then control many objects state with the slider.
You can actually do this without writing any code using my Datasacks package.
create a datasack to contain the value of that slider
create your slider and configure it
add a DSUserIntentSlider and hook up the datasack you made above, and set it to integer
make a new GameObject and add a GameObjectControl script to it, drag in the datasack you created, then start dragging / positioning items into the various methods of control.
Depending on how complex your turn-on-turn-off logic is, you might need more than one GameObjectControl configured slightly differently.
If you are using any version of Unity later than Unity2021, it may be necessary to add this line to your Packages/manifest.json, or add it via the Package Mangler:
Let me try my standard reply to these types of questions.
You have 10 objects that can be enabled/disabled. You create a class that can hold these. So if you had a Box class and had 10 of them you create a Boxes class that includes a collection (array or list but array would appear to work well in this case). The Boxes class includes a method EnableBoxes(int value).
Then “anything” can be used to enable the boxes. You can opt to have your slider call it.