From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Misc/GarbageCollectSharedAssets.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Runtime/Misc/GarbageCollectSharedAssets.h (limited to 'Runtime/Misc/GarbageCollectSharedAssets.h') diff --git a/Runtime/Misc/GarbageCollectSharedAssets.h b/Runtime/Misc/GarbageCollectSharedAssets.h new file mode 100644 index 0000000..a9a990d --- /dev/null +++ b/Runtime/Misc/GarbageCollectSharedAssets.h @@ -0,0 +1,31 @@ +#ifndef GARBAGE_COLLECT_SHARED_ASSETS_H +#define GARBAGE_COLLECT_SHARED_ASSETS_H + +/// Unloads all assets that are not referenced using dependency tracking and mono GC. +/// You must call GetPreloadManager().LockPreloading(); GetPreloadManager().UnlockPreloading(); around GarbageCollectSharedAssets. +void GarbageCollectSharedAssets (bool includeMonoReferencesAsRoots); + +/// Calculates all direct references of all loaded objects and additional categories +/// * loadedObjects is an array of all loaded objects +/// * additionalCategories is an array of all custom categories (eg. "SceneObject", "HideAndDontSave" etc) +/// * referencedObjectCount is the number of referenced objects (referencedObjectIndices holds the indices) +/// * referencedObjectIndices is a combined array of all indices (referencedObjectCount) +/// This is a stream layout so to make sense of the data you have to walk referencedObjectCount in linear order +#if ENABLE_MEM_PROFILER +void CalculateAllObjectReferences (dynamic_array& loadedObjects, dynamic_array& additionalCategories, dynamic_array& referencedObjectCount, dynamic_array& referencedObjectIndices); +#endif + +#if UNITY_EDITOR +bool ShouldPersistentDirtyObjectBeKeptAlive (int instanceID); + +/// Prevents an Object from being destroyed by GarbageCollectSharedAssets(). +/// This is useful in cases where an Object is internally created by code without ties +/// to the scene and needs to be kept alive across operations that may trigger an +/// asset GC run. +void SetPreventGarbageCollectionOfAsset (int instanceID); +/// Reverts previous call to SetPreventGarbageCollectionOfAsset(). +void ClearPreventGarbageCollectionOfAsset (int instanceID); + +#endif + +#endif -- cgit v1.1-26-g67d0