Stat Identity

Scripting with the StatIdentity class.

The StatIdentity class is used by a Stat to give itself rules and to separate itself from others.

Fields & Properties

Name
Description
Type
Access

displayName

The full stat name.

string

public

localizedDisplayNameKey

The key of the localized display name string.

string

public

abbreviation

The abbreviated name.

string

public

icon

An icon that represents the stat.

Sprite

public

color

The color scheme of the stat.

Color

public

useColorForIcon

If the color should be applied to the icon.

bool

public

enableAttributeStrictness

If true, stats of this identity will not be able to do mathematical operations with identities of the same type if their attributes are different.

bool

public

updateCurrentValueWithHighValue

Combined stats always affect the high value of a stat. With this enabled, the current value will be affected with it.

bool

public

numericType

The numeric type of this stat.

StatValue.NumericType

public

valueType

The value type of this stat. Value: treat the value as an exact value. Percent: treat the value as a percentage.

StatValue.ValueType

public

hasMin

If this stat has a min value.

bool

public

hasMax

If this stat has a max value.

bool

public

minValue

The minimum value.

StatValue

public

maxValue

The maximum value.

StatValue

public

Creating Stat Identities

It's not at all recommended to create stat identities at runtime, but it is possible. StatIdentity's are scriptable objects which cannot be created as assets at runtime for later use.

StatIdentity identity = ScriptableObject.CreateInstance<StatIdentity>();

The stat identity IDs must be unique. When creating them from the Stat IDs tab, unique IDs are set automatically. However, this is not done when creating them at runtime. You'd need to create your own method of ensuring IDs of generated stat identities are unique.

Getting Stat Identities

Stat identities created through the Stat IDs tab can be retrieved at runtime.

Get a Single Stat Identity

You can get a stat identity by its ID, name, or abbreviation with the Inventool.GetStatIdentity method.

StatIdentity myStatIdentity = Inventool.GetStatIdentity("HP");

Get All Stat Identities

var statIdentities = Inventool.GetAllStatIdentities();

Clamp

You can clamp a numeric value or StatValue within a StatIdentity's min and max ranges.

StatValue myStatValue = new StatValue(myStatIdentity, 100);
myStatValue = myStatIdentity.Clamp(myCurrencyValue);

Last updated