LoadResult

Summary: Inspect loaded data, errors and backup recovery information.

Description

LoadResult<T> is the outcome of reading data of type T. Check IsSuccess to see whether Data contains loaded data. A failed load can still return a non-null fallback in Data. Check RecoveredFromBackup if your game needs to react to recovery.

Namespace Gley.SaveSystem.

Declaration

C#
public class LoadResult<T>

Members

MemberTypeDescription
StatusSaveStatusFinal status of the load.
DataTLoaded data on success. On failure, defaultValue supplies the fallback if provided. Otherwise Save System creates an instance of T for value types and classes with a public parameterless constructor, and uses default(T) for other types. The fallback leaves Status unchanged.
IsSuccessboolTrue when Status is Success.
MessagestringExtra information about the outcome.
ExceptionExceptionThe associated exception, or null when none was recorded.
RecoveredFromBackupboolTrue if the result records a recovery from a temporary or backup copy.
RecoveredFromSaveStatus?The original failure that led to recovery, or null when there was no recovery.
QuarantinedTostringLocation of a quarantined or preserved broken copy, when one was recorded.
ChecksumIgnoredboolTrue if the load ignored a checksum mismatch for an unprotected save in the Editor.

Example

Create CheckLoadResult.cs, attach it to a GameObject and enter Play mode. Run the synchronous Save example once to create position-sync-example before trying this script.

C#
using Gley.SaveSystem;
using UnityEngine;

public class CheckLoadResult : MonoBehaviour
{
    private void Start()
    {
        LoadResult<Vector3> result = API.Load<Vector3>("position-sync-example");
        if (result.IsSuccess)
        {
            transform.position = result.Data;
        }

        Debug.Log($"Load status: {result.Status}", this);
    }
}
On This Page