EllanJiang/GameFramework · error · GameFrameworkException

Update resources complete callback is invalid.

Error message

Update resources complete callback is invalid.

What it means

This GameFrameworkException is thrown by ResourceManager.UpdateResources when updateResourcesCompleteCallback is null. The manager requires a completion callback to report when the resource group update finishes or fails, so it fails fast instead of starting an update that could never report its result. It is argument validation.

Solutions

  1. Pass a non-null UpdateResourcesCompleteCallback to UpdateResources.
  2. Initialize the callback field before invoking the update flow.
  3. Handle the completion (and any nested error reporting) in the provided callback rather than omitting it.

Example fix

// before
resourceManager.UpdateResources("MyGroup", null);
// after
resourceManager.UpdateResources("MyGroup", (group, success) => {
    UnityEngine.Debug.LogFormat("Update resource group '{0}' {1}.", group, success ? "complete" : "failed");
});
Defensive patterns

Strategy: validation

Validate before calling

if (updateCallback == null) throw new ArgumentNullException(nameof(updateCallback));
resourceManager.UpdateResources(groupName, updateCallback);

Type guard

bool HasCallback(UpdateResourcesCompleteCallback cb) => cb != null;

Try / catch

try { resourceManager.UpdateResources(groupName, callback); }
catch (GameFrameworkException ex) { UnityEngine.Debug.LogError($"UpdateResources failed: {ex.Message}"); }

Prevention

When it happens

Trigger: Calling UpdateResources(resourceGroupName, null); passing an uninitialized delegate field; refactors that removed the callback argument value.

Common situations: Hot-update code where the completion handler is conditionally assigned; wiring errors in custom update UI; unit tests calling the API without a handler.

Related errors


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

Appendix: source

Thrown at GameFramework/Resource/ResourceManager.cs:1301

        /// <summary>
        /// 使用可更新模式并更新所有资源。
        /// </summary>
        /// <param name="updateResourcesCompleteCallback">使用可更新模式并更新默认资源组完成时的回调函数。</param>
        public void UpdateResources(UpdateResourcesCompleteCallback updateResourcesCompleteCallback)
        {
            UpdateResources(string.Empty, updateResourcesCompleteCallback);
        }

        /// <summary>
        /// 使用可更新模式并更新指定资源组的资源。
        /// </summary>
        /// <param name="resourceGroupName">要更新的资源组名称。</param>
        /// <param name="updateResourcesCompleteCallback">使用可更新模式并更新指定资源组完成时的回调函数。</param>
        public void UpdateResources(string resourceGroupName, UpdateResourcesCompleteCallback updateResourcesCompleteCallback)
        {
            if (updateResourcesCompleteCallback == null)
            {
                throw new GameFrameworkException("Update resources complete callback is invalid.");
            }

            if (m_ResourceMode == ResourceMode.Unspecified)
            {
                throw new GameFrameworkException("You must set resource mode first.");
            }

            if (m_ResourceMode != ResourceMode.Updatable && m_ResourceMode != ResourceMode.UpdatableWhilePlaying)
            {
                throw new GameFrameworkException("You can not use UpdateResources without updatable resource mode.");
            }

            if (m_ResourceUpdater == null)
            {
                throw new GameFrameworkException("You can not use UpdateResources at this time.");
            }

            ResourceGroup resourceGroup = (ResourceGroup)GetResourceGroup(resourceGroupName);

View on GitHub (pinned to d0c010b051)