docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct StatValue

    This struct standardizes how stat values are serialized.

    Implements
    IDictionaryConvertible
    Namespace: UnityEngine.GameFoundation
    Assembly: solution.dll
    Syntax
    [Serializable]
    public struct StatValue : IDictionaryConvertible
    Remarks

    For fields that share the same memory space, only the bigger type will be serialized to avoid conflicting serialization and minimize the serialization size.

    Properties

    Name Description
    type

    Stat value type ('Int' or 'Float').

    Methods

    Name Description
    AsFloat()

    Explicitly casts this StatValue into a float, doing the necessary conversion if necessary, but throwing an InvalidCastException if not possible.

    AsInt()

    Explicitly casts this StatValue into an integer, doing the necessary conversion if necessary, but throwing an InvalidCastException if not possible.

    Equals(object)

    Indicates whether this instance and a specified object are equal.

    FillFromDictionary(Dictionary<string, object>)

    Reset this object and fill it with the given data.

    GetHashCode()

    Returns the hash code for this instance.

    ToDictionary()

    Converts this object to a JSON ready dictionary.

    ToString()

    Returns the fully qualified type name of this instance.

    Operators

    Name Description
    operator +(StatValue, StatValue)

    Add 2 StatValues together.

    operator ==(StatValue, StatValue)

    Compare 2 StatValues for equality.

    implicit operator StatValue(int)

    Construct a StatValue from an integer.

    implicit operator StatValue(float)

    Construct a StatValue from an float.

    implicit operator int(StatValue)

    The integer value for this stat if its type is 'Int'.

    implicit operator float(StatValue)

    The float value for this stat if its type is 'Float' else int value cast to a float.

    operator !=(StatValue, StatValue)

    Compare 2 StatValues for inequality.

    operator -(StatValue, StatValue)

    Subtract StatValue from another StatValue.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)