I'm trying to make my own video game in Unity. I have a series of biomes. They eventually evolve from bad to good, based on a float converted into an int going from 0 to 100, giving a biome Value of +1 or -1 when reaching 0 or 100, and reseting then the bar to the opposite. To that, I have a Biome.Text, which adjust itself according to the biome type.
It looks like that :
private void SetSkyBiomeType(int skyBiomeType)
{
skyBiomeType = Mathf.Clamp(skyBiomeType, 1, 8);
if (skyBiomeType == 1)
{
SkyBiomeType.text = "Dark Sky";
}
if (skyBiomeType == 2)
{
SkyBiomeType.text = "Cold Sky";
}
if (skyBiomeType == 3)
{
SkyBiomeType.text = "Dusty Sky";
}
}
But as I wanted to have more visibility on the bar progressing from one biome to another, I added two more texts, on the left and the right of the bar, showing the previous biome and the next biome.
So I adjusted my code to :
private void SetSkyBiomeType(int skyBiomeType)
{
skyBiomeType = Mathf.Clamp(skyBiomeType, 1, 8);
if (skyBiomeType == 1)
{
SkyPreviousBiomeType.text = " ";
SkyBiomeType.text = "Dark Sky"; ;
SkyNextBiomeType.text = "Dusty Sky";
}
if (skyBiomeType == 2)
{
SkyPreviousBiomeType.text = "Dark Sky";
SkyBiomeType.text = "Cold Sky";
SkyNextBiomeType.text = "Dusty Sky";
}
}
And so on.
And sure, it works. But I'm trying to make it more elegant by having something simple like :
skyPreviousBiomeType.text = skyBiomeType - 1;
skyBiomeType.text = skyBiomeType;
skyNextBiomeType.text = skyBiomeType + 1;
Of course, that doesn't work, because the .text cannot be equal to an int without set " ". So I'm kind of of lost there. Everything I read online about how to tie a .text to an int was about making a .ToString() but that's not really what I'm looking for, and can't seem to add and remove 1 from it. I want the .text to refer itself to the value of the int.
