EllanJiang/GameFramework · error · GameFrameworkException

Can not load binary ' ' which is not a binary asset.

Error message

Can not load binary '{0}' which is not a binary asset.

What it means

The resource name exists and is ready, but ResourceInfo.IsLoadFromBinary is false — the asset was packaged as an ordinary asset (scene/object, LoadType from assets) rather than a binary asset. LoadBinary refuses to return it and throws when no LoadBinaryFailureCallback is set.

Solutions

  1. Mark the file as a binary resource in the GameFramework resource editor and repackage so its LoadType is LoadFromBinary.
  2. If the asset is not meant to be binary, load it with LoadAsset instead of LoadBinary.
  3. Double-check the binaryAssetName so it does not collide with a non-binary packaged resource.
  4. Supply LoadBinaryFailureCallback to receive LoadResourceStatus.TypeError through the callback.

Example fix

// before
m_ResourceComponent.LoadBinary("Assets/GameAssets/UI/Logo.png", callbacks, userData); // packaged as normal asset
// after
// In resource editor: add the file to binary resources, then:
m_ResourceComponent.LoadBinary("Logo.png", callbacks, userData);
Defensive patterns

Strategy: validation

Validate before calling

// confirm the file is configured as a binary resource before calling
Debug.Assert(IsRegisteredBinaryResource(binaryName), $"{binaryName} must be marked as a binary resource in the resource editor.");

Type guard

bool IsBinaryResource(string name) => BinaryResourceManifest.Contains(name);

Try / catch

try { m_ResourceComponent.LoadBinary(binaryName, callbacks, userData); }
catch (GameFrameworkException ex) when (ex.Message.Contains("not a binary asset"))
{ Log.Error("{0} is packaged as a normal asset; use LoadAsset instead.", binaryName); }

Prevention

When it happens

Trigger: Calling LoadBinary/LoadBinaryAsync on an asset that was not placed in the binary resources list during packaging (e.g. a texture or text file not configured as binary in the resource editor).

Common situations: Developers assume any file can be loaded as binary; after reorganizing the resource package an asset moved from binary to normal assets; wrong asset name resolving to a different packaged resource.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


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

Appendix: source

Thrown at GameFramework/Resource/ResourceManager.ResourceLoader.cs:599

                    if (loadBinaryCallbacks.LoadBinaryFailureCallback != null)
                    {
                        loadBinaryCallbacks.LoadBinaryFailureCallback(binaryAssetName, LoadResourceStatus.NotReady, errorMessage, userData);
                        return;
                    }

                    throw new GameFrameworkException(errorMessage);
                }

                if (!resourceInfo.IsLoadFromBinary)
                {
                    string errorMessage = Utility.Text.Format("Can not load binary '{0}' which is not a binary asset.", binaryAssetName);
                    if (loadBinaryCallbacks.LoadBinaryFailureCallback != null)
                    {
                        loadBinaryCallbacks.LoadBinaryFailureCallback(binaryAssetName, LoadResourceStatus.TypeError, errorMessage, userData);
                        return;
                    }

                    throw new GameFrameworkException(errorMessage);
                }

                if (resourceInfo.UseFileSystem)
                {
                    loadBinaryCallbacks.LoadBinarySuccessCallback(binaryAssetName, LoadBinaryFromFileSystem(binaryAssetName), 0f, userData);
                }
                else
                {
                    string path = Utility.Path.GetRemotePath(Path.Combine(resourceInfo.StorageInReadOnly ? m_ResourceManager.m_ReadOnlyPath : m_ResourceManager.m_ReadWritePath, resourceInfo.ResourceName.FullName));
                    m_ResourceManager.m_ResourceHelper.LoadBytes(path, m_LoadBytesCallbacks, LoadBinaryInfo.Create(binaryAssetName, resourceInfo, loadBinaryCallbacks, userData));
                }
            }

            /// <summary>
            /// 从文件系统中加载二进制资源。
            /// </summary>
            /// <param name="binaryAssetName">要加载二进制资源的名称。</param>
            /// <returns>存储加载二进制资源的二进制流。</returns>

View on GitHub (pinned to d0c010b051)