Perhaps I have been staring at the same thing for two long but here it is
I have a dictionary that stores all my AttackPrototype classes and then this class which stores a List of all the attacks the weapon allows the character to do. I am writing an editor designer for the weapon that needs to have a GUILayout.Toggle() for each of the attacks, the attacks already in the myScript.Attacks need to start as already toggled true and I need to be able to toggle them on or off to add or remove from myScript.Attacks
Names = new List<string>();
trues = new bool[AD.Attacks.Values.Count];
List<AttackPrototype> attacksend = myScript.Attacks;
int index = 0;
int index2 = 0;
foreach(var Attack in AD.Attacks.Values)
{
GUILayout.Label(Attack.AttackName);
foreach(AttackPrototype attack in myScript.Attacks)
{
if(attack.AttackName == Attack.AttackName)
{
foreach (bool boole in trues)
{
if(index2 == index)
trues[index2]=true;
index2++;
}
}
}
index++;
}
index = 0;
foreach(var Attack in AD.Attacks.Values)
{
/*foreach(string attackn in Names)
{
if(attackn == Attack.AttackName)
trues[index] = true;
}*/
trues[index] = GUILayout.Toggle (trues[index],"");
index ++;
}
index = 0;
for (int x = 0; x<AD.Attacks.Values.Count; x++)
{
if(trues[x])
{
index = 0;
foreach(var Attack in AD.Attacks.Values)
{
if(index == x)
{
Names.Add(Attack.AttackName);
}
index++;
}
}
}
foreach (string name in Names)
{
attacksend.Add (AD.FindItem(name));
}
myScript.Attacks = attacksend;