Skip to content

ScriptableDictionary Class

Base class for all ScriptableDictionary<TKey, TValue>.

C#
[HelpURL("https://hertzole.github.io/scriptable-values/types/scriptable-dictionary")]
public abstract class ScriptableDictionary : RuntimeScriptableObject, INotifyPropertyChanging, INotifyPropertyChanged, IStackTraceProvider, ICanBeReadOnly, INotifyCollectionChanged

Inheritance object → UnityEngine.Object → UnityEngine.ScriptableObject → RuntimeScriptableObject

Implements INotifyPropertyChanging, INotifyPropertyChanged, IStackTraceProvider, ICanBeReadOnly, INotifyCollectionChanged

You should probably inherit from ScriptableDictionary<TKey, TValue> instead.

C#
public static readonly PropertyChangedEventArgs isReadOnlyChangedEventArgs
C#
public static readonly PropertyChangingEventArgs isReadOnlyChangingEventArgs
C#
public static readonly PropertyChangedEventArgs setEqualityCheckChangedEventArgs
C#
public static readonly PropertyChangingEventArgs setEqualityCheckChangingEventArgs
C#
public static readonly PropertyChangedEventArgs clearOnStartChangedEventArgs
C#
public static readonly PropertyChangingEventArgs clearOnStartChangingEventArgs
C#
public static readonly PropertyChangedEventArgs countChangedEventArgs
C#
public static readonly PropertyChangingEventArgs countChangingEventArgs

If true, an equality check will be run before setting an item through the indexer to make sure the new object is not the same as the old one.

C#
[CreateProperty]
public abstract bool SetEqualityCheck { get; set; }

If true, the ScriptableDictionary<TKey, TValue> will be cleared on play mode start/game boot.

C#
[CreateProperty]
public abstract bool ClearOnStart { get; set; }

Gets the number of key/value pairs contained in the ScriptableDictionary<TKey, TValue>.

C#
[CreateProperty]
public abstract int Count { get; protected set; }

If read only, the ScriptableDictionary<TKey, TValue> cannot be changed at runtime and won’t be cleared on start.

C#
[CreateProperty]
public abstract bool IsReadOnly { get; set; }

Warns if there are any left-over subscribers to the events.

C#
protected override void WarnIfLeftOverSubscribers()

This will only be called in the Unity editor and builds with the DEBUG flag.

Removes all keys and values from the ScriptableDictionary<TKey, TValue>.

C#
public abstract void Clear()

ReadOnlyException
If the object is read-only and the application is playing.

Ensures that the dictionary can hold up to a specified number of entries without any further expansion of its backing storage.

C#
public abstract int EnsureCapacity(int capacity)

capacity int
The number of entries.

int
The current capacity of the ScriptableDictionary<TKey, TValue>.

ArgumentOutOfRangeException
capacity is less than 0.

Sets the capacity of this ScriptableDictionary<TKey, TValue> to what it would be if it had been originally initialized with all its entries.

C#
public abstract void TrimExcess()

Sets the capacity of this ScriptableDictionary<TKey, TValue> to hold up a specified number of entries without any further expansion of its backing storage.

C#
public abstract void TrimExcess(int capacity)

capacity int
The new capacity.

ArgumentOutOfRangeException
capacity is less than the number of items in the ScriptableDictionary<TKey, TValue>.