49 lines
1.2 KiB
C#
Raw Normal View History

2024-12-16 17:53:28 +08:00
#if !UNITY_WEBGL
using UnityEngine;
#endif
namespace TTSDK
{
public class UnityCacheStorageStatus
{
public long maximumAvailableStorageSpace;
public long spaceOccupied;
public long spaceFree;
}
public static class UnityCacheCompatibility {
public static bool CheckAndSetMaxStorageSpace(long cacheSizeInBytes)
{
#if !UNITY_WEBGL
Cache cache = Caching.currentCacheForWriting;
if (null != cache && cache.maximumAvailableStorageSpace > cacheSizeInBytes)
{
cache.maximumAvailableStorageSpace = cacheSizeInBytes;
return true;
}
#endif
return false;
}
public static UnityCacheStorageStatus GetStorageStatus()
{
#if !UNITY_WEBGL
Cache cache = Caching.currentCacheForWriting;
if (null != cache)
{
return new UnityCacheStorageStatus
{
maximumAvailableStorageSpace = cache.maximumAvailableStorageSpace,
spaceOccupied = cache.spaceOccupied,
spaceFree = cache.spaceFree
};
}
#endif
return null;
}
}
}