# UnityEditor.AssetDatabase：无法在路径 'Packages/com.example.custompackage/Resources/MyAsset.asset' 加载资源。未找到资源。

- **ID:** `unity/assetdatabase-package-resource-not-found`
- **领域:** unity
- **类别:** resource_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

包内指定的路径不存在，通常是因为资源未放置在包内的“Resources”文件夹中，或者包未正确导入。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Unity 2022.3.8f1 | active | — | — |
| Unity 2023.1.1f1 | active | — | — |

## 解决方案

1. ```
   确保资源位于包内的“Resources”文件夹中。例如，创建文件夹结构：`Packages/com.example.custompackage/Resources/MyAsset.asset`。然后使用 `AssetDatabase.LoadAssetAtPath<ScriptableObject>("Packages/com.example.custompackage/Resources/MyAsset.asset")`。
   ```
2. ```
   如果包是本地包，则使用相对项目根目录的路径，例如 `Assets/MyResources/MyAsset.asset`，而不是包路径。
   ```
3. ```
   验证包是否已正确安装并在项目窗口的“包”下可见。如果不可见，请通过包管理器重新安装包。
   ```

## 无效尝试

- **** — Moving the resource to a different folder within the package without using a 'Resources' folder will still fail because AssetDatabase.LoadResourceAtPath only searches 'Resources' folders. (80% 失败率)
- **** — Reimporting the package does not help if the resource path is incorrect or the folder structure is wrong. (90% 失败率)
