Skip to main content

ResourcesCleanup

A class in Root.Township, the global namespace.

Runs Resources.UnloadUnusedAssets at the end of the frame, from a hidden object it makes on first use. Only one unload runs at a time.

Constructors​

MemberWhat it is
ResourcesCleanup()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

2 private and internal fields
MemberWhat it is
private static ResourcesCleanup instanceThe cleanup object, made on first Run.
private static bool isUnloadingTrue while an unload is in progress.

Methods​

MemberWhat it is
static void Run()Starts an end-of-frame unload in play mode if one isn't already running.
2 private and internal methods
MemberWhat it is
private void OnDestroy()Clears the unloading flag.
private static IEnumerator UnloadAtEndOfFrame() (iterator)Coroutine that waits for end of frame and unloads unused assets.