Sooo…another sleepless night(thanks insomnia)
What I’m trying to do is
-
Dynamically build a list of items from resource folder.
(That works right)
-
Dynamically build a list of UI text objects from another resource folder. (that works too)
-
Dynamically assign Each one of the UI texts.text to be the Item names. --Thats where I am having trouble at.
Instead of renaming each text to each name, it only names each one to the last Item’s name.
Oh where did I go wrong?
My guess would be because you are looping through all the objectsToFind
. And so it is only setting the last one. I think adding a return;
after _newName.text = _newItem.name
should do the trick.
If not, then I think this should. Maybe.
for (int i = 0; i < objectsToFind.length; i++)
{
_newName = (GameObject)Instantiate(objectToFind(i))
for (int j = 0; j < ItemName.length); j++)
{
_newName.text = _newItem.name;
}
}
Well, I got something working. Not as I wanted, but close enough for now.
Basically, I’m going for a hidden object game in 3d. Not the 2d, stare at a picture kind.
so far I have: `
for (int o = 0; o < objectsToFind.Count; o++)
{
_newItem = (GameObject)Instantiate(objectsToFind[o]);
ItemName.text += _newItem.name;
Debug.Log(ItemName.text);
}
`
That shows each instantiated item’s names in 1 text.
Next steps are to remove the “(clone)” from the names and add spaces in between each name.
Then when item clicked, remove its name from the text list.
Thanks for the help!