CrabUI
Loading...
Searching...
No Matches
Serialization

All components are serializable
Every property marked with [CUISerializable] is serializable

Every type that have Parse and ToString methods can be serialized
For types that doesn't have them methods from CUIExtensions will be used

Also you can parse/serialize simple types manually with CUIParser

You can save and load them to / from file like this:

public void SaveToFile(string path, CUIAttribute propAttribute = CUIAttribute.CUISerializable)
public static CUIComponent LoadFromFile(string path, bool saveAfterLoad = false)
public static T LoadFromFile<T>(string path, bool saveAfterLoad = false)
public void LoadFromTheSameFile()
public void SaveToTheSamePath()

Right after the component is loaded, its Hydrate method is called
Also note that Deserialization doesn't remove children so be careful not to create duplicates

Props:

  • bool Serializable - if false component won't be serialized
  • bool SerializeChildren - if false children of this component won't be serialized
  • bool ReplaceSerialization - When deserialized this component will replace existing sibling with matching AKA
  • bool MergeSerialization - This component won't be deserialized, but its children will be attached to the sibling with matching AKA

Also you can memorize and restore state of component

States are just shalow clones of component
They are stored in

ComponentA.States

You can manipulate them with:

ComponentA.SaveStateAs(string name)
ComponentA.LoadState(string name)
ComponentA.ForgetState(string name)
ComponentA.ApplyState(CUIComponent state)

Also you can clone component with

ComponentA.Clone()