Info

Usage

New definition type

  1. Inherit AUniqueDefinition (AListedDefinition for kinds lists show) and add [AddressableDefinition("MyKind", "Definition")], plus [ManagementPanel] for its page in App Management
  2. Create the assets and apply the validator fix "Fix addressables" for address, group, label and prefab entries
  3. For PurrNet add packer extensions (see AvatarDefinitionPackerExtensions)
  4. Reference prefabs, fonts and other heavy assets by address. A preloaded definition loads everything it references directly at boot

Example

[AddressableDefinition("MyKind", "Definition")]
public class MyDefinition : AUniqueDefinition { }

public static class MyDefinitionPackerExtensions
{
    public static void Write(this BitPacker packer, MyDefinition value) => packer.CustomWriteTranslatedDefinition(value);
    public static void Read(this BitPacker packer, ref MyDefinition value) => value = packer.CustomReadTranslatedDefinition<MyDefinition>();
}

// Available definitions, kept current
private DefinitionList<MyDefinition> _definitions;

private void Awake()
{
    _definitions = new DefinitionList<MyDefinition>();
    _definitions.Changed += Refresh;
}

private void OnDestroy() => _definitions.Dispose();