
1.3.3 管理项目文件
在游戏开发过程中,一般会在“项目”面板中进行文件的管理。除了支持导入各种格式的资源文件,Unity还支持导入和导出Unity的资源包。资源包中包含了大量的资源文件和脚本,使用起来非常方便快捷。
1.导入资源文件
导入普通的资源文件有如下两种方式,读者可根据自己的喜好选择合适的方式。
第1种方式,在桌面上创建一个文本文件或图片文件,准备将该文件导入Unity。在“项目”面板中的任意位置单击鼠标右键,在弹出的菜单中选择“导入新资源”选项,如图1-36所示。

图1-36
在弹出的“导入新资源”对话框中选择要导入的资源,单击“导入”按钮即可将资源文件导入Unity,如图1-37所示。

图1-37
第2种方式,将文件拖曳到“项目”面板中,也可完成文件的导入,如图1-38所示。

图1-38
2.导出资源包
尝试将刚导入的文件导出。在“项目”面板中选择希望导出的文件(如果想要导出多个文件,那么多选文件即可),然后单击鼠标右键,在弹出的菜单中选择“导出包”选项,如图1-39所示。

图1-39
在“导出项”对话框中勾选希望导出的文件,然后单击“导出”按钮,如图1-40所示。设置资源包保存的位置和名称后保存即可。

图1-40
导出成功后,Unity资源包的扩展名为.unitypackage,如图1-41所示。

图1-41
3.导入资源包
除了可以导入普通的资源文件,Unity还可以导入资源包。资源包中包含了大量的资源文件和脚本。与导入资源文件的操作类似,导入资源包的方式有如下3种。
第1种方式,在“项目”面板中的任意位置单击鼠标右键,在弹出的菜单中选择“导入包>自定义包”选项,如图1-42所示。

图1-42
在弹出的对话框中选择需要导入的资源包,然后单击“打开”按钮即可,如图1-43所示。

图1-43
第2种方式,将资源包拖曳到“项目”面板中,也可以完成资源包的导入,如图1-44所示。

图1-44
第3种方式,双击资源包文件,在Import Unity Package(导入Unity资源包)对话框中勾选需要导入的资源文件,然后单击“导入”按钮即可,如图1-45所示。

图1-45
技巧提示
如果要导入的资源文件在“项目”面板中已存在,则该资源文件不会显示在对话框中。