清理现有的Unity项目并将其迁移到新的一台或另一台PC中 [英] Cleaning up and Migrating existing Unity project into new one or another PC

查看:1349
本文介绍了清理现有的Unity项目并将其迁移到新的一台或另一台PC中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将现有的Unity项目复制到一个新的空白Unity项目中.似乎所有对象引用和许多脚本都没有在我的场景的层次结构中正确配置/存在.

I wish to copy my existing Unity project into a new blank Unity project. It appears all the object references and many scripts are not configured properly/present in the Hierarchy in my scenes.

我只将我的资产文件夹/package.json复制到了新的Unity项目中,因为其余文件很脏,并且缓存了很多无用的信息.

I only copied my assets folder/package.json into the new Unity project, because the rest of the files are dirty and have cached a lot of useless information.

文件在哪里,详细说明了场景数据所在的位置?我想将其复制过来,以便可以使用所有对象引用和脚本将场景运行到正确的游戏对象上. >

Where are the files, detailing the scenes data located? I want to copy that over so I can run my scenes with all the object references, and scripts set onto the correct game objects.

推荐答案

开始之前,请务必进行备份-您永远不会知道!


清理

通常,您将始终需要AssetsProjectSettings文件夹.

Before starting always make Backups - you never know!


Cleaning Up

In general you will always need the Assets and the ProjectSettings folder.

您可以删除的所有其余内容,当您再次打开项目时,Unity将重新创建/重新编译它们.

All the rest you can delete and Unity will recreate/recompile them when you open the project again.

另请参见幕后

备份项目或将项目添加到版本控制存储库时,应包括Unity主项目文件夹,该文件夹同时包含资产 ProjectSettings 文件夹. 这些文件夹中的所有信息对于Unity的工作方式至关重要.

When backing up a project, or adding a project to a Version Control Repository, you should include the main Unity project folder, containing both the Assets and ProjectSettings folders. All the information in these folders is crucial to the way Unity works.

顾名思义

  • Assets是脚本,图像,预制件等所有资产,包括其他场景.
  • ProjectSettings是项目的所有常规设置,例如质量,物理特性,演奏者弦等.
  • Assets are all your assets like scripts, images, prefabs etc. including alse the scenes.
  • ProjectSettings are all general settings for your project regarding things like quality, physics, player strings etc

对我来说,某些Library/*.asset文件也可以保留..它们存储例如构建设置,目标平台等.因此,我不必在每次重置"时从头开始配置它们/切换平台.当然,您也要这样做.

For me also some of the Library/*.asset files make sense to keep .. they store e.g. the build settings, target platform etc. so I don't have to configure them / switch platform from scratch everytime I "reset". It's up to you of course if you want to do this as well.

您也可以使用任何其他版本控制系统...或者当然也可以手动删除相应的文件夹和文件,但是我始终使用

You can also use any other version control system ... or of course also remove according folders and files manually but I always use GIT for my projects.

另请参阅将外部版本控制系统与Unity配合使用,以获取有关以下方面的一些常规信息:用于控制项目的版本的设置.

Also refer to Using external version control systems with Unity for some general information about the setup for version controlling your project(s).

因此,当我想在处理存储库之前对其进行清理时,我通常将以下内容用作*.gitignore(还有更完整的版本,例如

So when I want to clean up a repository before coping it I usually use the following as *.gitignore (there are also more complete versions e.g. the one from Github).

这里列出的所有内容基本上都可以删除,并且下次您在Unity中打开项目时将重新编译它们. (以!开头的行是我添加的例外,因为如我所说,也应保留这些行.)

Everything listed here can basically be deleted and will be re-compiled the next time you open the project in Unity. (Lines starting with ! are exceptions I added because as said for me it made sense to keep those as well.)

/.out/
/[Ll]ibrary/*
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/Assets/AssetStoreTools*
/UWP/

# Visual Studio cache directory
/.vs/

# Autogenerated VS solution and project files
/ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb

# Unity3D generated meta files
*.pidb.meta
*.pdb.meta

# Unity3D Generated File On Crash Reports
**/sysinfo.txt

# keep the *.asset files from Library
!/[Ll]ibrary/*.asset

如果尚未完成,请先初始化运行中的存储库

If not done yet first initialize the repository running

cd your/project/root/path
git init
git add *

这将为.gitignore中列出的每个文件显示一些警告,但是您可以忽略这些警告.它只说类似

this will show some warnings for every file that is listed in the .gitignore but you can ignore those warnings. It only says something similar like

您正在尝试将一个忽略的文件添加到提交中,它将被跳过

You are trying to add an ignored file to the commit and it will be skipped

比运行

git commit -m "Initial commit"

进行第一次提交.

现在终于可以运行

git clean -xfd

会删除所有未未跟踪的文件(因此请确保始终将您想要的所有文件至少保留在暂存状态(git add)或更佳地首先提交),否则将被*.gitignore忽略.

which removes every file that is not tracked (so be sure to have always all files you want to keep at least staged (git add) or better commited first) or would be ignored by the *.gitignore.

-f
如果Git配置变量clean.requireForce未设置为false,除非给定-f,-n或-i,否则git clean将拒绝删除文件或目录.除非给出第二个-f,否则Git将拒绝删除具有.git子目录或文件的目录.

-f
If the Git configuration variable clean.requireForce is not set to false, git clean will refuse to delete files or directories unless given -f, -n or -i. Git will refuse to delete directories with .git sub directory or file unless a second -f is given.

-d
未跟踪文件外,还删除未跟踪目录.如果未跟踪的目录由其他Git存储库管理,则默认情况下不会将其删除.如果您确实要删除这样的目录,请使用-f选项两次.

-d
Remove untracked directories in addition to untracked files. If an untracked directory is managed by a different Git repository, it is not removed by default. Use -f option twice if you really want to remove such a directory.

-x
不要使用从.gitignore(每个目录)和$ GIT_DIR/info/exclude中读取的标准忽略规则,但仍要使用-e选项提供的忽略规则.这允许删除所有未跟踪的文件,包括构建产品.可以使用它(可能与git reset结合使用)创建一个原始的工作目录,以测试干净的构建.

-x
Don’t use the standard ignore rules read from .gitignore (per directory) and $GIT_DIR/info/exclude, but do still use the ignore rules given with -e options. This allows removing all untracked files, including build products. This can be used (possibly in conjunction with git reset) to create a pristine working directory to test a clean build.


使用UnityPackage迁移

在两个不同项目之间移动场景或部分资产的另一种方法是使用 UnityPackage


Migrating using UnityPackage

Another option for moving scenes or parts of the Assets between two different projects is using a UnityPackage

从当前项目中导出UnityPackage

From your current project export a UnityPackage

文档摘录:

使用导出程序包"创建自己的自定义程序包.

Use Export Package to create your own Custom Package.

  1. 打开要从中导出资产的项目.

  1. Open the Project you want to export Assets from.

选择资产→从菜单中单击导出软件包,以弹出导出软件包"对话框. (请参阅导出包对话框图像 下面.)

Choose AssetsExport Package from the menu to bring up the Exporting Package dialog box. (See Exporting Package dialog box image below.)

在对话框中,通过单击框选择要包含在包中的资产,以便选中它们.

In the dialog box, select the Assets you want to include in the package by clicking on the boxes so they are checked.

保持选中包含依赖项"框,以自动选择您选择的资产所使用的任何资产.

Leave the include dependencies box checked to auto-select any Assets used by the ones you have selected.

单击导出"以打开文件浏览器,然后选择要存储打包文件的位置.

Click on Export to bring up the file explorer, and choose where you want to store your package file.

命名并保存程序包.

提示:导出软件包时,Unity可以将所有依赖项导出为 出色地.因此,例如,如果您选择一个场景"并使用 所有依赖项,然后Unity导出所有模型,纹理和其他 资产也出现在场景中.这可能是一种快速的方法 无需手动查找即可导出多个资产.

HINT: When exporting a package Unity can export all dependencies as well. So, for example, if you select a Scene and export a package with all dependencies, then Unity exports all Models, Textures and other Assets that appear in the Scene as well. This can be a quick way of exporting several Assets without manually locating them all.

或者,也可以在Project ViewAssets文件夹上单击右键单击,然后在上下文菜单中找到 Export Package 选项.

alternatviely to step 2 you can also Right-Click on the Assets folder in the Project View and find the Export Package option in the context menu.

,然后在新项目中导入UnityPackage

and then in the new project Import the UnityPackage

要导入资产包,请执行以下操作:

To import an Asset package:

  1. 打开您要将资产导入到的项目.
  2. 选择资产导入包自定义程序包.
  3. 在文件资源管理器中,选择所需的软件包,然后会出现导入Unity软件包"对话框,其中的所有项目均已预先检查,可以安装. (请参见下面的导入Unity软件包"对话框图像.)
  4. 选择 Import ,然后Unity将软件包的内容放入Assets文件夹,您可以从Project view进行访问.
  1. Open the Project you want to import Assets into.
  2. Choose AssetsImport PackageCustom Package.
  3. In the file explorer, select the package you want and the Import Unity Package dialog box appears, with all the items in the package pre-checked, ready to install. (See Import Unity Package dialog box image below.)
  4. Select Import and Unity puts the contents of the package into the Assets folder, which you can access from your Project view.

或者,除了24步骤,您甚至可以通过Unity编辑器将unitypackage文件拖放到Assets文件夹中.

Alternatively to step 2 and 4 you can even simply drag and drop the unitypackage file into the Assets folder via the Unity Editor.

这篇关于清理现有的Unity项目并将其迁移到新的一台或另一台PC中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆