Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.
Porrith Suong edited this page Aug 30, 2019 · 4 revisions

ReactiveDisposal is built upon Unity's Entity Component System and helps manage unsafe memory on any entity.

API Reference

For the API, please look here

QuickStart

Installing

For now, you can install this by adding this as a submodule to your project.

git submodule add https://github.com/InitialPrefabs/ReactiveDisposal.git <path-to-desired-directory>

// Example assuming that your root directory is your project's home
git submodule add https://github.com/InitialPrefabs/ReactiveDisposal.git Assets/ReactiveDisposal

Usage

All derivative systems should derive from the ReactiveDisposalSystem<T>, where T is confined to a struct, implements an ISystemStateComponentData and IDisposable interface.

unsafe struct UnmanagedData : ISystemStateComponentData, IDisposable {
    public int* Value;

    public void Dispose() {
        if (Value != null) {
            Memory.Free(Value);
        }
    }
}

To allow a system to free this memory:

class DisposeDataSystem : ReactiveDisposalSystem<UnmanagedData> {

    protected override JobHandle OnUpdate(JobHandle inputDeps) {
        return ScheduleDisposalJob(inputDeps);
    }
}

For more detailed info about ReactiveDisposalSystem<T> please see here.

Clone this wiki locally