diff options
author | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
commit | 15740faf9fe9fe4be08965098bbf2947e096aeeb (patch) | |
tree | a730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Misc/GarbageCollectSharedAssets.h |
Diffstat (limited to 'Runtime/Misc/GarbageCollectSharedAssets.h')
-rw-r--r-- | Runtime/Misc/GarbageCollectSharedAssets.h | 31 |
1 files changed, 31 insertions, 0 deletions
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<Object*>& loadedObjects, dynamic_array<const char*>& additionalCategories, dynamic_array<UInt32>& referencedObjectCount, dynamic_array<UInt32>& 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 |