I'm trying to think about how I can create a health/stamina gauge in the GUI based on the current health variable / max health variable for instance, and the best I can come up with now is to use scene objects and the 3D menu framework.
However, if I want this gauge to show up in every scene it would be a bit of a hassle to have to add those gauge objects to each scene, so some option to do that in the menu manager would be nice.
To be specific, all I want is a simple bar whose horizontal size increases/decreases depending on the relationship of two variables. Nothing more complex than that... even allowing us to base menu element size on variables should be enough to get what I'm after. Thanks!
Comments
PlayerMenus.GetElementWithName ("StatsMenu", "HealthBar");
will return an element called HealthBar in a menu called StatsMenu. You can adjust the width of the element with it's slotSize.x variable. To base it on that of a Variable value, you need the variable ID, which is to the left of it's name in the Variables Manager. I'll make things easier in the next update, but this function will return the value of an integer variable:
int GetIntValue (int ID)
{
foreach (GVar _var in GameObject.FindWithTag (Tags.persistentEngine).GetComponent <RuntimeVariables>().localVars)
{
if (_var.id == ID)
{
return _var.val;
}
}
return 0;
}