ソースコード
using System.Linq;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.AddressableAssets;
public class Example : MonoBehaviour
{
private static readonly string[] ERROR_MESSAGES =
{
"Disk full.",
};
private async void Start()
{
await Addressables.InitializeAsync().Task;
await UpdateCatalogs();
}
private static async Task UpdateCatalogs()
{
var isDiskFull = false;
void OnLogMessageReceivedThreaded( string condition, string trace, LogType type )
{
if ( isDiskFull ) return;
if ( type == LogType.Log || type == LogType.Warning ) return;
isDiskFull = ERROR_MESSAGES.Any( x => condition.Contains( x ) );
Application.logMessageReceivedThreaded -= OnLogMessageReceivedThreaded;
}
Application.logMessageReceivedThreaded += OnLogMessageReceivedThreaded;
var result = Addressables.UpdateCatalogs();
await result.Task;
Application.logMessageReceivedThreaded -= OnLogMessageReceivedThreaded;
if ( isDiskFull )
{
Debug.LogError( "ディスクの空き容量が不足している" );
return;
}
Debug.Log( "成功" );
}
}