Currency Identity

💳 CurrencyIdentity Class

Provides an identity to a Currency and sets basic rules.

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


📦 Fields

Access
Field
Type
Description

private

pathInResources

string (const)

The path used with Resources.LoadAll to find currency identity assets.

public

icon

Sprite

The display icon of this currency.

public

displayName

string

The currency's display name.

public

localizedDisplayNameKey

string

The key of the localized display name string.

public

code

string

The currency's code.

public

symbol

string

The currency's symbol.

public

numericType

NumericType

The currency numeric type.

public

hasMin

bool

If this currency has a minimum value.

public

hasMax

bool

If this currency has a maximum value.

public

minIntegerValue

int

The minimum value (integer).

public

maxIntegerValue

int

The maximum value (integer).

public

startingIntegerValue

int

The starting value (integer).

private

minDecimalValueAsString

string

The minimum value (decimal) as a string. Serialized.

private

maxDecimalValueAsString

string

The maximum value (decimal) as a string. Serialized.

private

startingDecimalValueAsString

string

The starting value (decimal) as a string. Serialized.

public

minFloatValue

float

The minimum value (float).

public

maxFloatValue

float

The maximum value (float).

public

startingFloatValue

float

The starting value (float).


🔍 Properties

Access
Property
Type
Description

public

MinDecimalValue

decimal

The minimum value (decimal).

public

MaxDecimalValue

decimal

The maximum value (decimal).

public

StartingDecimalValue

decimal

The starting value (decimal).


🧰 Methods

Access
Method
Returns
Description

public

GetLocalizedDisplayName()

string

Gets the localized display name string.

public

Clamp(Currency.Value value)

Currency.Value

Clamps a value within the min and max range.

public

Clamp(Currency currency)

Currency

Clamps a currency within the min and max range.

public

Clamp(decimal value)

decimal

Clamps a decimal value within the min and max range.

public

Clamp(float value)

float

Clamps a float value within the min and max range.

public

Clamp(int value)

int

Clamps an integer value within the min and max range.

public

SetData(CurrencyIdentity identity)

void

Sets the data from another currency identity.

public static

GetObject(int id)

CurrencyIdentity

Gets the CurrencyIdentity by ID.

public static

Create(string name)

CurrencyIdentity

Creates a new instance of a CurrencyIdentity (editor only).

public static

CreateCopy(CurrencyIdentity original, string name)

CurrencyIdentity

Creates a copy of another CurrencyIdentity.

private static

GetID()

int

Returns an unused ID.


🧩 Nested Types

public enum NumericType

The value type of a currency.

Name
Description

Decimal

The value is stored as a decimal.

Integer

The value is stored as an integer.

Float

The value is stored as a float.


Creating Currency Identities

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

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

The currency identity IDs must be unique. When creating them from the Currencies 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 currency identities are unique.

Getting Currency Identities

Currency identities created through the Currencies tab can be retrieved at runtime.

Get a Single Currency Identity

You can get a currency identity by its ID, code, or symbol with the Inventool.GetCurrencyIdentity method.

CurrencyIdentity myCurrencyIdentity = Inventool.GetCurrencyIdentity("MyCurrencyCode");

Get All Currency Identities

var currencyIdentities = Inventool.GetAllCurrencyIdentities();

Clamp

You can clamp a numeric value or Currency within a CurrencyIdentity's min and max ranges.

Currency myCurrency = new Currency(myCurrencyIdentity);
myCurrency = myCurrencyIdentity.Clamp(myCurrency);

Last updated