注意:如果要共享场景、示例、工具或其他资源,Unity 建议创建您自己的资源包。但是,也可以使用资源包 (.unitypackage
) 格式。例如,您可能想要创建一个资源包,将多个资源或整个场景从一个项目复制到另一个项目。
按本节中的说明,从 Unity 编辑器的 Assets 菜单中导出资源包。
注意:如果您的资源质量很高,并且您相信其他用户会认为它们很有用,请按照 发布到 Asset Store 文档中的说明创建资源包草案并将其上传到 Asset Store
要创建您自己的自定义资源包,请执行以下操作:
打开要从中导出资源的项目。
从菜单中选择 Assets > Export Package 以打开 Exporting package 对话框。
在此对话框中,通过单击复选框来选择要包含在资源包中的资源。
将 Include dependencies 保持启用状态,即可自动选择已选资源使用的所有资源。
单击 Export 以打开文件资源管理器,然后选择要存储资源包文件的位置。
为资源包命名,并将其保存任何所需位置。
提示:导出资源包时,Unity 也可以导出所有依赖项。因此,例如,如果选择一个场景并导出包含所有依赖项的资源包,那么 Unity 也将导出场景中出现的所有模型、纹理和其他资源。这是导出多个资源的快捷方法,无需手动定位所有资源。
注意:如果您选择了 “Include dependencies”,并且当前的选择包含或引用了任何脚本,Unity 将在您的项目中包含所有脚本。这是因为 Unity 无法确定您的选择中使用的脚本是否引用了其他脚本。例如,如果您在项目中选择要导出的场景资源,并且该场景包含一个附加了脚本的游戏对象,则项目中的所有脚本都将被视为依赖项。如果您不希望出现这种行为,应取消选中 “Include dependencies”。
如果要更改资源包的内容并创建资源包的更新版本,请在资源包中选择所需的资源文件(未更改的资源文件和新的资源文件)。然后,按照上述说明导出文件。
请使用增量式名称来重命名更新的资源包:例如,MyAssetPackageVer1
、MyAssetPackageVer2
。Unity 会将其识别为更新,因此您应该使用对您和您与之共享的所有人而言都明确的命名约定。
警告:不要从资源包中删除文件,然后添加具有相同名称的不同文件。Unity 使用唯一的 ID 来跟踪文件,因此它会将它们识别为不同并可能相互冲突的文件。在这些情况下,Unity 在导入它们时会显示警告符号。如果已删除文件然后决定替换它,请将其重命名(即使它与原始名称很接近)。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.