Hey guys so basically what i need to know is:
I instantiate UI objects and assign the names of the objects from a list.
this game object has a script attached that has all of the UI elements of the game object defined.
I do this so it is easier to reference. Part of this script references 2 ui buttons one upp and one down.
I created OnClick listeners and this is where my brain stops working.
see code below then I will ask question:
foreach (Base_Attribute atts in attribs)
{
uis = Instantiate(att_prefab, attContainer.transform.position, transform.rotation);
uis.transform.SetParent(attContainer.transform, false);//= skill_Container.transform;
uis.GetComponent<AttributeUILayout>().nametext.text = atts.attributeName;
uis.GetComponent<AttributeUILayout>().amountText.text = atts.GetCurrentLevel().ToString();
uis.GetComponent<AttributeUILayout>().upButton.onClick.AddListener(() => UpLevelAttribute());
uis.GetComponent<AttributeUILayout>().downButton.onClick.AddListener(() => DownLevelAttribute());
}
}
public void UpLevelAttribute()
{
if(attributePoints>=1)
{
attributePoints--;
}
}
public void DownLevelAttribute()
{
if (attributePoints >= 0)
{
attributePoints++;
}
}
}
So basically I have a class called Base_Attribute, I have a Attribute manger attached to player, and also a character creation class attached to the UI, that checks how many base_attributes are in the list on the attributeManager.And assigns them to the UI accordingly. The sceen looks like this https://i.imgur.com/naglwLz.jpg
So basically when i click the button on say strength I would like to change the current level of strength but i can figgure out how to check what button was actually clicked then get the script attached?
can someone help please?