Show / Hide Table of Contents

Class ValueStore

Unity compatible store of nested string key/value pairs.

Inheritance
System.Object
ValueStore
Implements
UnityEngine.ISerializationCallbackReceiver
Namespace: sttz.Trimmer
Assembly: Trimmer.dll
Syntax
[Serializable]
public class ValueStore : ISerializationCallbackReceiver
Remarks

The ValueStore is used to serialize the nested Option values in Unity using its ISerializationCallbackReceiver callbacks.

Properties

| Improve this Doc View Source

RootCount

Number of root nodes in this store.

Declaration
public int RootCount { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Roots

Enumerate the root nodes in this store.

Declaration
public IEnumerable<ValueStore.RootNode> Roots { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<ValueStore.RootNode>

Methods

| Improve this Doc View Source

AddRoot(String, String)

Add a new root node.

Declaration
public ValueStore.RootNode AddRoot(string name, string value)
Parameters
Type Name Description
System.String name
System.String value
Returns
Type Description
ValueStore.RootNode
| Improve this Doc View Source

Clear()

Removes all content form the store.

Declaration
public void Clear()
| Improve this Doc View Source

Clone()

Create a clone of the current store.

Declaration
public ValueStore Clone()
Returns
Type Description
ValueStore
| Improve this Doc View Source

GetOrCreateRoot(String)

Get a root node by name, create it if it doesn't exist.

Declaration
public ValueStore.RootNode GetOrCreateRoot(string name)
Parameters
Type Name Description
System.String name
Returns
Type Description
ValueStore.RootNode
| Improve this Doc View Source

GetRoot(String)

Get a root node by name.

Declaration
public ValueStore.RootNode GetRoot(string name)
Parameters
Type Name Description
System.String name
Returns
Type Description
ValueStore.RootNode
| Improve this Doc View Source

IsDirty(Boolean)

Check if the store has been modified and optionally reset the modification state.

Declaration
public bool IsDirty(bool clear = false)
Parameters
Type Name Description
System.Boolean clear
Returns
Type Description
System.Boolean
| Improve this Doc View Source

RemoveRoot(String)

Remove a root node.

Declaration
public void RemoveRoot(string name)
Parameters
Type Name Description
System.String name

Explicit Interface Implementations

| Improve this Doc View Source

ISerializationCallbackReceiver.OnAfterDeserialize()

Declaration
void ISerializationCallbackReceiver.OnAfterDeserialize()
| Improve this Doc View Source

ISerializationCallbackReceiver.OnBeforeSerialize()

Unity doesn't support serialization of types that contain themselves, like in this case Node that contains lists of Node. To enable this we don't serialize the nested lists but instead just the size of the lists (i.e. Node.numVariants and Node.numChildren) and then use ISerializationCallbackReceiver to flatten and unpack the tree before and after Unity serializes it.

We process the nodes in the same order flattening and unpacking them and that allows us to get away with just serializing the list lengths.

Declaration
void ISerializationCallbackReceiver.OnBeforeSerialize()

Implements

UnityEngine.ISerializationCallbackReceiver
  • Improve this Doc
  • View Source
Back to top © 2017 Adrian Stutz