I am trying to obtain the selection order of three simple cubes.
It works super simple, I just use the mouse cursor to select one of the cubes, then the second and finally the third. Each time in a different order, so I would like to display de selection order as an int. Any ideas?
Sorry for the bad explanation. I just want to have the gameobject selection order as a number (1, 2, 3…), I made a mistake writing it and I wrote “float”. Hope it helps to clarify the mistake.
Sorry for the bad explanation. I just want to have the gameobject selection order as a number (1, 2, 3…), I made a mistake writing it and I wrote “float”. Hope it helps to clarify the mistake.
Sorry for the bad explanation. I just want to have the gameobject selection order as a number (1, 2, 3…), I made a mistake writing it and I wrote “float”. Hope it helps to clarify the mistake.
Well you want this as an int?
It’s more efficient to just have them in a list
so right now you know what order you select when you click them, you must have a list already for them all to be selected.
This list already has the order of selection?
But for the sakes of it, you’ll probably have to use a string, or else when you will reach double digits in the int chain for example 10 selected objects and you will confuse the int reading system that I am about to design for you. So the system you are about to see will only function from 0-9 selected objects
you must assemble the int by string, so you’ll need to have both a string and an int and your selection list.
But Wait,
how have you selected your objects? via a component present individually on all objects? If so; you’ll need a controller script. So each component selected who ticks himself selected; also adds to a list in this controller script. Or else; you remove the ability to select them by component, and instead select everything in the controller script. The controller script throws them into a list and the list IS the order that you selected them in. If this would then still need to become an int. well, the int is always going to be 123456789. But let’s say
let’s say your objects have int attached to them. And they are numbered for example; so that you already know the number as if a tag on the object
so object 1 was highlighted object 2 was highlighted object 6 was highlighted
they need to talk to a controller script and create a string += “1” this will only work for 0-9 objects
then after this you use int try parse to turn it into an int?
And instead create a script in that’s script make a public List. On your objects when selected they must reference this script and add themself to it. This is all you really need to do. When they are unselected they simply remove themself from it