Ok so what i need is this:
I have a Inventory made out of gameobjects, so no GUI, each “Slot” gameObject will have a child object floating in it representing the item it holds.
Whenever the void UpdateInventory() is called i want each child object (Slot1,Slot2,Slot3) to check if there is a child object inside them, if there is i want the child object to be stored in the Slot1,Slot2,Slot3 Variables.
I know it sounds a bit weird… If you have any suggestions to do it differently i would love to hear them.
This is what i have:
public class Inventory : MonoBehaviour {
public GameObject Slot1;
public GameObject Slot2;
public GameObject Slot3;
void UpdateInventory(){
foreach(Transform child in transform){
if(transform.GetChild (0) != null){
(GameObject)this.GetType().GetField (child.name).SetValue (child.transform.GetChild (0));
}
}
}
Hope i made atleast a little bit of sence in what i am trying to accomplish.
Thanks if you decide to help me.