#string format
1 messages · Page 1 of 1 (latest)
Right, but can I still write it like
abilityText.text = string.Format("After you place a {0}, {1}", myCard.myValue, myCard.myText)?
I fear that any references to {0} in {1} will be lost
That's the main situation right here
like I want myText to be able to be formatted replacing {0} with myValue
the reason being for this specific card's effects
Ability: One-Upmanship – After you place a 4, choose another character in play (either living or dead). That player’s ability becomes your ability, except the required die value to activate it or use any of its effects is 4.
in this instance shouldn't I only use string.format with one variable, being the value?
i'll test it out
kay it worked lmao
not sure what you meant. {0} is just referring to myCard.myValue . . .
so you just use {myCard.myValue} instead . . .
so instead of using {0} to point to myCard.myValue, you just use the variable instead. hope that makes sense. you just remove the middleman . . .
It makes sense, it just wasn't what I was after since it would massively bloat the text I'd need to write.
This solution ended up producing what you see below, thanks again.
string tempAbilText = "<b>After you place a {0},</b> " + myCard.abilityText;
if(myCard.abilityNote.Length > 0){
abilityText.text += "\r\n<i>" + myCard.abilityNote + "</i>";
}
abilityText.text = string.Format(tempAbilText, myCard.charRole);```
oh, i see. that's a different situation . . .
your setup involves text from the inspector, not code . . .
This is to accomodate certain cards which may take on different text and need to read different things depending on the situation.
Yeah, it's scriptable objects
i'd still use string interpolation to avoid concatenation (+) as that is the slowest version between: concat, format, interpolation, and string builder . . .