Stat Identity

🆔 StatIdentity Class

Represents the identity of a stat.

Namespace: Esper.Inventool.Stats Access: public Type: class Inherits: InventoolObject


📦 Fields

Access
Field
Type
Description

public

displayName

string

The full stat name.

public

localizedDisplayNameKey

string

The key of the localized display name string.

public

abbreviation

string

The abbreviated name.

public

icon

Sprite

Icon representing the stat.

public

color

Color

Color scheme of the stat.

public

useColorForIcon

bool

If true, applies the color to the icon.

public

enableAttributeStrictness

bool

If true, prevents operations with same identity but different attributes.

public

updateCurrentValueWithHighValue

bool

If true, combined stats affect both high and current values.

public

numericType

NumericValue.NumericType

The numeric type of this stat.

public

valueType

StatValue.ValueType

The value type of this stat.

public

hasMin

bool

If this stat has a minimum value.

public

hasMax

bool

If this stat has a maximum value.

public

minValue

StatValue

The minimum value.

public

maxValue

StatValue

The maximum value.


🔍 Properties (Editor Only)

Access
Property
Type
Description

public static

DirectoryPath

string

Path to the directory where stat assets are stored (Editor only).


🧰 Methods

Access
Method
Returns
Description

private

OnValidate()

void

Ensures min/max values are linked to this identity. Saves if changed.

public

GetLocalizedDisplayName()

string

Gets the localized display name string.

public

Clamp(NumericValue.Value value)

NumericValue.Value

Clamps a raw numeric value within min/max.

public

Clamp(StatValue stat)

StatValue

Clamps a stat value within min/max.

public

Clamp(float value)

float

Clamps a float within min/max.

public

Clamp(int value)

int

Clamps an int within min/max.

public

SetData(StatIdentity statIdentity)

void

Copies data from another identity.

public static

Create()

StatIdentity

Creates a new stat identity (Editor only).

public

UpdateAssetName()

void

Updates the asset name in the editor.

public static

GetFullPath(StatIdentity statIdentity)

string

Gets the full path of a stat identity (Editor only).

public static

CreateCopy(StatIdentity original)

StatIdentity

Creates a copy of another stat identity.

private static

GetID()

int

Returns an unused ID.


🔄 Implicit Conversions

Conversion
Description

int -> StatIdentity

Converts an integer ID into a StatIdentity via Inventool.GetStatIdentity(id).

string -> StatIdentity

Converts a string (name or abbreviation) into a StatIdentity via Inventool.GetStatIdentity(nameOrAbbreviation).


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