[Edited]
Hi everyone.
How do I keep the original name of a game object?
This is my original name game object.
I have a button to change its name in editor mode. It adds index at the front of the original name based on the list.
But when click the button again it become like this.
This is my code:
So back to my question, how do I add index at the front without change the original name “Abutment Sleeve”.
What I want is like:
0 | Item 1
1 | Item 2
2 | Item 3
…
It sounds and looks like you are clicking more than once. Each time you click it is looping over the list and changing each item right? So it keeps appending the same value on earlier items. So either change the item you click on or check whether it has been changed already. Mr. Panda is simply saying you can check for the pipe char and remove it (if it exists) before you change it. Me? I would check if it has been changed and simply skip that one.
I hope the list is long and warrants writing code to modify the names
Yup, it supposed to click more than once. There are 20-30 items in the list on average. So everytime I click the button (to auto populate the list) it auto changes the item name according to index in the list.
Well unless you record the original names of the game objects, you’re going to have to parse the string and make sure you don’t double up on your formatting.