{"record":{"id":"32ec0662abcdb446","repo":"CoplayDev/unity-mcp","slug":"could-not-load-audio-data","errorCode":null,"errorMessage":"Could not load audio data","messagePattern":"Could not load audio data","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Previews/Scripts/Generators/Custom/TypeGenerators/AudioTypePreviewGenerator.cs","lineNumber":96,"sourceCode":"                    var texture = GenerateAudioClipTexture(audioClip);\r\n\r\n                    var outputPath = GenerateOutputPathWithExtension(audioClip, _settings.PreviewFileNamingFormat, _settings.Format);\r\n                    var bytes = PreviewConvertUtility.ConvertTexture(texture, _settings.Format);\r\n                    File.WriteAllBytes(outputPath, bytes);\r\n                    generatedPreviews.Add(ObjectToMetadata(audioClip, outputPath));\r\n                }\r\n\r\n                OnAssetProcessed?.Invoke(i, audioClips.Count);\r\n                await Task.Yield();\r\n            }\r\n\r\n            return generatedPreviews;\r\n        }\r\n\r\n        private Texture2D GenerateAudioClipTexture(AudioClip audioClip)\r\n        {\r\n            if (!audioClip.LoadAudioData())\r\n                throw new Exception(\"Could not load audio data\");\r\n\r\n            try\r\n            {\r\n                if (_texture == null)\r\n                    _texture = new Texture2D(_settings.Width, _settings.Height);\r\n                else\r\n#if UNITY_2021_3_OR_NEWER || UNITY_2022_1_OR_NEWER || UNITY_2021_2_OR_NEWER\r\n                    _texture.Reinitialize(_settings.Width, _settings.Height);\r\n#else\r\n                    _texture.Resize(_settings.Width, _settings.Height);\r\n#endif\r\n\r\n                FillTextureBackground();\r\n                FillTextureForeground(audioClip);\r\n\r\n                _texture.Apply();\r\n                return _texture;\r\n            }\r","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Previews/Scripts/Generators/Custom/TypeGenerators/AudioTypePreviewGenerator.cs#L78-L114","documentation":"Thrown when AudioClip.LoadAudioData() returns false during audio waveform texture generation. LoadAudioData attempts to load the compressed audio data into memory for sample access. Failure means the clip's data could not be decoded — the clip may be corrupted, streaming-type without data on disk, or not yet imported.","triggerScenarios":"Calling GenerateAudioClipTexture(audioClip) where audioClip.LoadAudioData() returns false. This occurs inside the per-asset preview generation loop in AudioTypePreviewGenerator.","commonSituations":"Audio clip is a streaming-compressed format whose underlying file was moved or deleted; clip import failed silently; clip is a synthesized/runtime AudioClip not backed by an asset file; audio file is corrupted; the clip's preload setting is disabled and background loading hasn't completed.","solutions":["Reimport the audio asset in Unity (right-click > Reimport) to ensure data is decoded.","Check that the audio file on disk is valid and not corrupted.","Ensure the AudioClip import settings have 'Preload Audio Data' enabled or wait for load completion before generating previews.","Filter out clips where LoadAudioData fails and log them as skipped rather than aborting the entire batch."],"exampleFix":"// before\nif (!audioClip.LoadAudioData())\n    throw new Exception(\"Could not load audio data\");\n\n// after\nif (!audioClip.LoadAudioData())\n{\n    ASDebug.LogWarning($\"Skipping {audioClip.name}: audio data could not be loaded.\");\n    continue;\n}","handlingStrategy":"try-catch","validationCode":"// Check loadability before generating preview\nif (!audioClip.LoadAudioData())\n{\n    Debug.LogWarning($\"Skipping preview for {audioClip.name}: cannot load audio data.\");\n    continue;\n}\n// Optionally wait for load completion\nwhile (audioClip.loadState == AudioDataLoadState.Loading)\n    await Task.Yield();","typeGuard":"static bool CanLoadAudioData(AudioClip clip)\n{\n    if (clip == null) return false;\n    // Check if the clip is backed by a valid asset path\n    var path = AssetDatabase.GetAssetPath(clip);\n    return !string.IsNullOrEmpty(path) && File.Exists(path);\n}","tryCatchPattern":"try\n{\n    var texture = GenerateAudioClipTexture(audioClip);\n}\ncatch (Exception ex) when (ex.Message.Contains(\"Could not load audio data\"))\n{\n    ASDebug.LogWarning($\"Skipping {audioClip.name}: audio data unavailable. Reimport may be needed.\");\n    continue; // skip this clip, continue batch\n}","preventionTips":["Enable 'Preload Audio Data' in the AudioClip import settings for preview assets.","Reimport audio assets before batch preview generation.","Filter out streaming or runtime-generated clips that lack persistent data.","Check audioClip.loadState before attempting sample access."],"tags":["unity","asset-store-tools","preview","audio","asset-loading"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}