- Home /
Description texts for upgradeable abilities
I have an ability system with abilities that can be upgraded to different levels and I am looking for a way to retrieve a description text for the ability to show in various dialogs.
The way I am currently doing it consists of a general description text for the ability containing %1, %2 etc values that are replaced by a quite complex piece of code that actually requires a lot of specific code for each separate ability. I have attached a screenshot of how the ability object looks like, as well as the text that I am getting.
My question is, how could I go about making a general system to hand me descriptions for the abilities without me requiring to write separate code for each case? I would prefer to use StringBuilder to avoid making lots of garbage.
I'm assu$$anonymous$$g you mean with the styling of the fonts? Why not just use rich text and using that in your description field. You can then just pass a string.
No the question doesn't have to do with the styling, but with the general system that makes a description out of an ability and it's attribute values.
Hard to say without knowing what the various possible variables are and no code to go by. $$anonymous$$ind of looks like you just need to do;
var level = Ability.Level;
string Description = "Blast an area dealing " + Ability.Float1[level].ToString() + " + " + Ability.Float2[level].ToString() + "% of enemy health." + Ability.DamageType + " damage to all enemies in an " + Ability.Float3[level].ToString() + " unit area of effect";
You can add the other ability level values as well if you like. Just use a string builder and some loops.
Your answer
![](https://koobas.hobune.stream/wayback/20220612194250im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
GetComponent via String name? 3 Answers
Build variable name using string 2 Answers
Fastest C# Byte[] to String conversion? 1 Answer
Searching XML document 2 Answers