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.
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.
Before starting always make Backups - you never know!
Cleaning Up
In general you will always need the
Assets
and theProjectSettings
folder.All the rest you can delete and Unity will recreate/recompile them when you open the project again.
Also see Behind the Scenes
As the names say
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 etcFor 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.Also refer to Using external version control systems with Unity for some general information about the setup for version controlling your project(s).
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).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.)If not done yet first initialize the repository running
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 likethan run
to make your first commit.
Now finally you can run
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
.Migrating using UnityPackage
Another option for moving scenes or parts of the Assets between two different projects is using a UnityPackage
From your current project export a UnityPackage
Excerpts from the Docs:
alternatviely to step
2
you can also Right-Click on theAssets
folder in theProject View
and find the Export Package option in the context menu.and then in the new project Import the UnityPackage
Alternatively to step
2
and4
you can even simply drag and drop theunitypackage
file into theAssets
folder via the Unity Editor.