EllanJiang/GameFramework · critical · GameFrameworkException

Decrypt resource callback is invalid.

Error message

Decrypt resource callback is invalid.

What it means

The decrypt resource callback is invoked whenever an encrypted resource must be decrypted during loading. GameFramework treats it as mandatory in LoadResourceAgent's constructor, so passing null throws this error.

Solutions

  1. Provide a DecryptResourceCallback when initializing the resource module; it can be a no-op (return the input bytes) if you do not use encryption.
  2. Upgrade-proof custom initialization code to match the current GameFramework resource API signature.
  3. Register the callback before any LoadAsset call so agents are never constructed without it.

Example fix

// before
resourceComponent.Initialize(...) // no decrypt callback passed
// after
DecryptResourceCallback decryptCallback = (bytes) => bytes; // no-op if unencrypted
resourceComponent.Initialize(..., decryptCallback);
Defensive patterns

Strategy: validation

Validate before calling

DecryptResourceCallback callback = decryptCallback ?? ((bytes) => bytes); // no-op default
if (decryptResourceCallback == null)
    throw new ArgumentNullException(nameof(decryptResourceCallback));

Try / catch

try
{
    resourceComponent.Initialize(..., decryptCallback);
}
catch (GameFrameworkException ex) when (ex.Message.Contains("Decrypt resource callback"))
{
    Debug.LogError("Provide a DecryptResourceCallback (use a no-op if unencrypted).");
}

Prevention

When it happens

Trigger: Constructing LoadResourceAgent with a null DecryptResourceCallback, even when no encrypted resources are expected (the ctor validates it unconditionally).

Common situations: Setting up a game with no resource encryption and therefore omitting the callback argument; using an overload/API change (version upgrade) that made the callback a required parameter; wiring the callback after initialization.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/7224190253bf6a42. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/Resource/ResourceManager.ResourceLoader.LoadResourceAgent.cs:64

                {
                    if (loadResourceAgentHelper == null)
                    {
                        throw new GameFrameworkException("Load resource agent helper is invalid.");
                    }

                    if (resourceHelper == null)
                    {
                        throw new GameFrameworkException("Resource helper is invalid.");
                    }

                    if (resourceLoader == null)
                    {
                        throw new GameFrameworkException("Resource loader is invalid.");
                    }

                    if (decryptResourceCallback == null)
                    {
                        throw new GameFrameworkException("Decrypt resource callback is invalid.");
                    }

                    m_Helper = loadResourceAgentHelper;
                    m_ResourceHelper = resourceHelper;
                    m_ResourceLoader = resourceLoader;
                    m_ReadOnlyPath = readOnlyPath;
                    m_ReadWritePath = readWritePath;
                    m_DecryptResourceCallback = decryptResourceCallback;
                    m_Task = null;
                }

                public ILoadResourceAgentHelper Helper
                {
                    get
                    {
                        return m_Helper;
                    }
                }

View on GitHub (pinned to d0c010b051)