Hi,
I’m a beginner in Unity and C#. I’ve spent hours and hours watching tutorials but I’m not sure what would be the best way to address following issue :
-
I will have on one single screen 100 UI “elements” displayed in ten lines of 10 columns. These elements will show no value in the begin. In my idea, each element could have two “properties” like LineName and ColumnNo.
-
when the user clicks on one of the elements, the system will calculate something based on the LineName and ColumnNo of this element (and other calculation parameters that I don’t need to describe here) and display the result in the element.
-
I would like to be able to “undo” the player’s choice. This means I need to know the last element that has been clicked after process. It would also be great if it was possible to set a backcolor to the selected element. After that, the player will click on a button to validate his choice, this would set the backcolor to default. The “Undo” option could be a button that retrieves the last clicked element and that sets the value back to null and the color to default.
-
I don’t want to use a grid because of display purposes.
My questions :
Q1 : what kind of UI element would best suit to this expected behaviour ?
- Text ? I saw a video where the person added a component to the UI Text in order to change its display properties (change color on MouseMove, change value onMouseClick…)
- Input Text (the user won’t input anything) ?
- Buttons ? The Onclick event is available, the highlighted color is a standard behaviour, I know I can change the text shown by the button, etc… but it’s strange for me to use buttons for that purpose.
- another UI element ?
Q2 : do I have to call the function that calculates the result on each of the 100 elements or is there a way to avoid this ? I dream of an “OnClick” event shared by all the 100 elements that would do the job based on the element’s “address” (LineName and ColumnNo).
Q3 : has someone seen something that looks like this in a sample project or a tutorial I could have a look at ?
I hope that at least one person has understood what I’m trying to do…
Thanks for any answer.