Skip to documentation
LITHIUM
Guide 02

Own a feature from load to shutdown.

Addon is the smallest lifecycle boundary in Lithium — one manifest, one initialization path and an explicit teardown.

Lifecycle

Lithium assigns the manifest before calling OnAddonLoaded. When that callback completes, IsLoaded becomes true. During shutdown, OnAddonUnloaded runs once for every loaded addon.

If loading throws, Lithium invokes teardown before rethrowing the error, allowing partially-created resources to be released.

  • Manifest is available after initialization begins.
  • IsInitialized reports whether a manifest has been assigned.
  • IsLoaded only becomes true after a successful load callback.

Identity with Addon

The Addon attribute supplies the id and display name used to construct the runtime manifest. Keep ids lowercase and namespace them to your studio or organization.

HouseAddon.cs
using Lithium.Addons;

namespace Lithium.House;

[Addon("thepanicdept.lithium_house", "Lithium House")]
public sealed class HouseAddon : Addon
{
    protected override void OnAddonLoaded()
    {
        var root = new GameObject { Name = "House Component" };
        root.AddComponent<HouseComponent>();
    }
}

Manifest data

AddonManifest exposes Id, Name, Dependencies and LoadPriority. Dependencies can be required or optional and carry a version requirement string.

AddonManifest.cs
var manifest = new AddonManifest
{
    Id = "thepanicdept.lithium_inventory",
    Name = "Lithium Inventory",
    LoadPriority = 20,
    Dependencies =
    [
        new AddonDependency(
            "thepanicdept.lithium_house",
            "*",
            IsOptional: true
        )
    ]
};
Cette page vous a-t-elle aidé ?

N’indiquez aucune donnée personnelle dans votre commentaire.

0/1000