- Home /
Is there a way to use dynamic variables with scriptable objects in the editor?
For example, say I want to make a scriptable object ability with the description "Increases damage by 20%", but I want the 20% value to come from a variable somewhere else based on the situation. So really I want the description to be more like "Increases damage by [battleEffects.damageIncreaseIncrement]". But all I have in the editor is a text area string. If this is not possible, are there some helpful patterns to get around it?
some like
public string description: "Increases damage by " + battleEffects.damageIncreaseIncrement;
in C# operator +
to [string] + [almost all number types] convert to string the number value
or the variable description in the editor like
/// <summary>
/// Increases damage by [battleEffects.damageIncreaseIncrement]
/// </summary>
public float modifier = basedamage*battleEffects.damageIncreaseIncrement;
press tree times /
to get the pattern
Are you saying you can do this in the text area in the editor on a scriptable object?
Answer by xxmariofer · Jan 15, 2019 at 08:49 AM
Hello, you can access that var but you need a reference, You can assign from insppector the scriptable object [serializefield]private int damage = 20;
public void SetDamage(int newDamage)
and in other script with the scriptable object reference callthe SetDamage method.
Your answer
