Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Packages/MobileSupportStorage/Runtime/MobileSupport.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"includePlatforms": [
"Android",
"Editor",
"iOS"
"iOS",
"WindowsStandalone64"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
Expand Down
39 changes: 39 additions & 0 deletions Packages/MobileSupportStorage/Runtime/Scripts/Storage.Windows.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// --------------------------------------------------------------
// Copyright 2026 CyberAgent, Inc.
// --------------------------------------------------------------

#if UNITY_STANDALONE_WIN
using System.Runtime.InteropServices;
using UnityEngine;

namespace MobileSupport
{
public static class Storage
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetDiskFreeSpaceEx(
string lpDirectoryName,
out ulong lpFreeBytesAvailable,
out ulong lpTotalNumberOfBytes,
out ulong lpTotalNumberOfFreeBytes);

/// <summary>
/// Get usable space of internal storage.
/// </summary>
/// <returns>Bytes of usable space. It will return -1 for internal error and in Unity editor.</returns>
public static long GetInternalUsableSpace()
{
#if UNITY_EDITOR
if (Application.isEditor) return -1;
#endif

if (GetDiskFreeSpaceEx(Application.persistentDataPath,
out var freeBytesAvailable, out _, out _))
return (long)freeBytesAvailable;

return -1;
}
}
}
#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.