Ceci n'est pas tres évident de donné les informations dans le sujet
Voiçi mon probleme lorsque j ouvre mon inventaire cela crée toute une série de boutons en fonction du NB de slot voulu:
Jusque la aucun soucis....
Par contre j ai un probleme pour identifier les slots...
J'aimerais que le 1er slots soit le N° 1 seconde 2 3eme 3 etc
Voiçi mon code actuel
Code : Tout sélectionner
for(var y = 0; y < 5; y++)
{
for(var x = 0; x < 5 ; x++)
{
for(var j = 0; j < 5 ; j++)
{
if(GUI.Button(Rect(12.5 + (55*x),25 + (50*j), 50, 50), "" + Inventory[y].name))
{
if(ClickLeft == true)
{
//equipe l objet a son emplacements
if(Inventory[y].typeOfEquipe == Inventory[x].typeOfEquipe.Pantalon)
{
if(EquipeMenu[0] == null)
{
EquipeMenu[0] = Inventory[y];
Inventory.RemoveAt(y);
}
else
{
Inventory.Add(EquipeMenu[0]);
EquipeMenu[0] = Inventory[y];
Inventory.RemoveAt(y);
}
}
else if(Inventory[y].typeOfEquipe == Inventory[x+j].typeOfEquipe.Veste)
{
if(EquipeMenu[1] == null)
{
EquipeMenu[1] = Inventory[y];
Inventory.RemoveAt(y);
InventorySlotIsEmpty ();
}
else
{
Inventory.Add(EquipeMenu[1]);
EquipeMenu[1] = Inventory[y];
Inventory.RemoveAt(y);
InventorySlotIsEmpty ();
}
}
else if(Inventory[y].typeOfEquipe == Inventory[y].typeOfEquipe.Chaussures)
{
if(EquipeMenu[2] == null)
{
EquipeMenu[2] = Inventory[y];
Inventory.RemoveAt(y);
InventorySlotIsEmpty ();
}
else
{
Inventory.Add(EquipeMenu[2]);
EquipeMenu[2] = Inventory[y];
Inventory.RemoveAt(y);
InventorySlotIsEmpty ();
}
}
}
if(ClickRight == true)
{
Debug.Log("affiche un menu pour" + Inventory[y].name); //todo
}
}
}
}
}
J'ai voulus testé avec une incrémentation ... Probleme nous somme dans un OnGUI donc constament mis a jours
J'ai voulu testé avec :
Code : Tout sélectionner
for(var x = 0; x < 5 ; x++)
{
if(CanCreateSlots == true && NbSlotsCreate !=NbSlots)
{
NbSlotsCreate++;
for(var j = 0; j < 5 ; j++)
{
if(GUI.Button(Rect(12.5 + (55*x),25 + (50*j), 50, 50), "" + Inventory[NbSlotsCreate].name))
{
if(ClickLeft == true)
{
//equipe l objet a son emplacements
if(Inventory[NbSlotsCreate].typeOfEquipe == Inventory[x].typeOfEquipe.Pantalon)
{
if(EquipeMenu[0] == null)
{
EquipeMenu[0] = Inventory[NbSlotsCreate];
Inventory.RemoveAt(NbSlotsCreate);
}
else
{
Inventory.Add(EquipeMenu[0]);
EquipeMenu[0] = Inventory[NbSlotsCreate];
Inventory.RemoveAt(NbSlotsCreate);
}
}
else if(Inventory[NbSlotsCreate].typeOfEquipe == Inventory[NbSlotsCreate].typeOfEquipe.Veste)
{
if(EquipeMenu[1] == null)
{
EquipeMenu[1] = Inventory[NbSlotsCreate];
Inventory.RemoveAt(NbSlotsCreate);
}
else
{
Inventory.Add(EquipeMenu[1]);
EquipeMenu[1] = Inventory[NbSlotsCreate];
Inventory.RemoveAt(NbSlotsCreate);
}
}
else if(Inventory[NbSlotsCreate].typeOfEquipe == Inventory[NbSlotsCreate].typeOfEquipe.Chaussures)
{
if(EquipeMenu[2] == null)
{
EquipeMenu[2] = Inventory[NbSlotsCreate];
Inventory.RemoveAt(NbSlotsCreate);
}
else
{
Inventory.Add(EquipeMenu[2]);
EquipeMenu[2] = Inventory[NbSlotsCreate];
Inventory.RemoveAt(NbSlotsCreate);
}
}
}
if(ClickRight == true)
{
Debug.Log("affiche un menu pour" + Inventory[NbSlotsCreate].name); //todo
}
}
}
}
}
et avec :
Code : Tout sélectionner
for(var x = 0; x < 5 ; x++)
{
if(CanCreateSlots == true && NbSlotsCreate !=NbSlots)
{
NbSlotsCreate++;
for(var j = 0; j < 5 ; j++)
{
if(GUI.Button(Rect(12.5 + (55*x),25 + (50*j), 50, 50), "" + Inventory[NbSlotsCreate].name))
{
if(ClickLeft == true)
{
//equipe l objet a son emplacements
if(Inventory[NbSlotsCreate].typeOfEquipe == Inventory[x].typeOfEquipe.Pantalon)
{
if(EquipeMenu[0] == null)
{
EquipeMenu[0] = Inventory[NbSlotsCreate];
Inventory.RemoveAt(NbSlotsCreate);
}
else
{
Inventory.Add(EquipeMenu[0]);
EquipeMenu[0] = Inventory[NbSlotsCreate];
Inventory.RemoveAt(NbSlotsCreate);
}
}
else if(Inventory[NbSlotsCreate].typeOfEquipe == Inventory[NbSlotsCreate].typeOfEquipe.Veste)
{
if(EquipeMenu[1] == null)
{
EquipeMenu[1] = Inventory[NbSlotsCreate];
Inventory.RemoveAt(NbSlotsCreate);
}
else
{
Inventory.Add(EquipeMenu[1]);
EquipeMenu[1] = Inventory[NbSlotsCreate];
Inventory.RemoveAt(NbSlotsCreate);
}
}
else if(Inventory[NbSlotsCreate].typeOfEquipe == Inventory[NbSlotsCreate].typeOfEquipe.Chaussures)
{
if(EquipeMenu[2] == null)
{
EquipeMenu[2] = Inventory[NbSlotsCreate];
Inventory.RemoveAt(NbSlotsCreate);
}
else
{
Inventory.Add(EquipeMenu[2]);
EquipeMenu[2] = Inventory[NbSlotsCreate];
Inventory.RemoveAt(NbSlotsCreate);
}
}
}
if(ClickRight == true)
{
Debug.Log("affiche un menu pour" + Inventory[NbSlotsCreate].name); //todo
}
}
}
}
else
{
NbSlotsCreate = 0;
}
}
Merci de votre aide