public void CalculateWidget()
{
int canvasWidth = FullHeart.width * (_playerHealthSystem.MaxHP / 2);
int fullHearts = _playerHealthSystem.HP / 2;
int halfHearts = _playerHealthSystem.HP % 2;
int deadHearts = (_playerHealthSystem.MaxHP / 2) - (_playerHealthSystem.HP / 2);
Texture2D tex = new Texture2D(canvasWidth, FullHeart.height);
int i = 0;
for(int counter = 0; counter < fullHearts; counter++)
{
tex.SetPixels(i, 0, FullHeart.width, FullHeart.height, FullHeart.GetPixels());
i += FullHeart.width;
}
for(int counter = 0; counter < halfHearts; counter++)
{
tex.SetPixels(i, 0, FullHeart.width, FullHeart.height, HalfHeart.GetPixels());
i += FullHeart.width;
}
for(int counter = 0; counter < deadHearts; counter++)
{
tex.SetPixels(i, 0, FullHeart.width, FullHeart.height, NoHeart.GetPixels());
i += FullHeart.width;
}
tex.Apply();
_fullUiWidget = tex;
UiWidget.Image = _fullUiWidget;
}