Hi Hi, probably something simple I’m missing and I should not be obsessing over this right now but I am.
I wrote up a little tooltip script which makes a popup appear when you hover anything with a separate script attached. Then the popup changes its text to match what is stored on the separate script instance, and ez pz tooltip engaged.
However, I cam currently trying to to get it worked out so the tooltip can only be so wide, before it wrap the text onto a new line. Currently this is all but achieved with this code. (Jank hobby code warning)
void displayCustom(string toDisplay)
{
string editedString = toDisplay;
int x = 0;
int y = 0;
int controlNum = 23;
while (x < editedString.Length)
{
if (y >= controlNum)
{
for (int Zee = 0; Zee < controlNum; Zee++)
{
if ( editedString[x - Zee].Equals(' '))
{
editedString.Remove(x - Zee, 1);
editedString = editedString.Insert(x - Zee, "
");
x += 4;
y = 0;
Zee = controlNum;
}
}
}
else
{
y++;
x++;
}
}
displayText.text = editedString;
}
However, the line editedString.Remove(x - Zee, 1); does nothing. I’ve moved it around, tried to tell it to remove more than 1, and can confirm it’s doing truly nothing. And since it is doing nothing, I’m getting some annoying indentation on my popup.
without that line, if If I set the controlValue to say 7 and give the popup the line “Thanks for nothing”
it will display
Thanks
for
nothing
with the line it displays the same thing, so idk if I’m using remove() wrong or if there is a more-correct way of doing this but any help would be appreciated.