EllanJiang/GameFramework · error · GameFrameworkException
Apply resources complete callback is invalid.
Error message
Apply resources complete callback is invalid.
What it means
This GameFrameworkException is thrown by ResourceManager.ApplyResources when the caller passes a null applyResourcesCompleteCallback. The resource manager refuses to start applying a resource pack without a completion callback because it must be able to notify the caller when the apply operation finishes. It is a fail-fast argument validation guard.
Solutions
- Pass a non-null ApplyResourcesCompleteCallback delegate as the second argument to ApplyResources.
- If the callback is a stored field, initialize it before calling ApplyResources (or assert it is not null first).
- Check the call site for refactors that accidentally dropped the callback argument.
Example fix
// before
resourceManager.ApplyResources(packPath, null);
// after
resourceManager.ApplyResources(packPath, (success) => {
UnityEngine.Debug.LogFormat("Apply resources {0}.", success ? "complete" : "failed");
}); Defensive patterns
Strategy: validation
Validate before calling
if (callback == null) throw new ArgumentNullException(nameof(callback)); resourceManager.ApplyResources(packPath, callback);
Type guard
bool HasCallback(ApplyResourcesCompleteCallback cb) => cb != null;
Try / catch
try { resourceManager.ApplyResources(packPath, callback); }
catch (GameFrameworkException ex) { UnityEngine.Debug.LogError($"ApplyResources failed: {ex.Message}"); } Prevention
- Always supply a completion callback when calling ApplyResources.
- Initialize callback fields at declaration or in init, not conditionally.
- Assert non-null arguments in wrappers around resource APIs.
When it happens
Trigger: Calling ResourceManager.ApplyResources(resourcePackPath, null), or passing a callback variable that has not been initialized (e.g. a field left null before the call).
Common situations: Callback wiring removed during refactors; conditional code paths where the callback is assigned only in some branches; calling ApplyResources from generated or wrapped code that forwards a null delegate.
Related errors
- Update resources complete callback is invalid.
- Resource name is invalid.
- Resource extension is invalid.
- Asset is invalid.
- Scene asset name is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/b0c13004717538b2.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Resource/ResourceManager.cs:1261
/// 使用可更新模式并应用资源包资源。
/// </summary>
/// <param name="resourcePackPath">要应用的资源包路径。</param>
/// <param name="applyResourcesCompleteCallback">使用可更新模式并应用资源包资源完成时的回调函数。</param>
public void ApplyResources(string resourcePackPath, ApplyResourcesCompleteCallback applyResourcesCompleteCallback)
{
if (string.IsNullOrEmpty(resourcePackPath))
{
throw new GameFrameworkException("Resource pack path is invalid.");
}
if (!File.Exists(resourcePackPath))
{
throw new GameFrameworkException(Utility.Text.Format("Resource pack '{0}' is not exist.", resourcePackPath));
}
if (applyResourcesCompleteCallback == null)
{
throw new GameFrameworkException("Apply 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 ApplyResources without updatable resource mode.");
}
if (m_ResourceUpdater == null)
{
throw new GameFrameworkException("You can not use ApplyResources at this time.");
}
m_ApplyResourcesCompleteCallback = applyResourcesCompleteCallback;View on GitHub (pinned to d0c010b051)