For now, i create a list of items.
What i wanna do is to create a gameobject (cube for example) each time i add an item into my list.
The difficulty is : how can i link my gameobject with the specific item of my list ?
Does somebody already tried? (Succeeded?)
Dictionary.
If you have an object management system, a handy way to track what in-world GameObject it is associated with is simply to have either a single GameObject reference in your object management structure, or else have a list of them, if a given object might have more than one GameObject representing it.
Also, be sure that you are maintaining the distinction between a object’s definition and its instance. You may want to have three potions in-game at once, and each one would point to a different actual GameObject, obviously.
Just put the GameObject in the list.
Or use a dictionary.
As i’ve already a list, i’ve put my gameObject inside.
But when i remove an element, it don’t destroy gameobject, so i should use Destroy.
I’ve searched for two hours how to destroy a gameobject in list but people say to use Destroy function but not how to use it on list.
(i’m newbie, never use list before and use unity only since 2 months)
public List<GameObject> myList;
void SomeMethod (){
Destroy (myList[0]);
myList.RemoveAt(0);
}
Thanks BoredMormon.
It works fine now.