使用SVN进行Unity3d版本管理总结

来源:互联网 发布:小众社交软件 编辑:程序博客网 时间:2024/05/16 19:51

使用Unity3D也有一段时间了,由于团队一直使用SVN进行版本管理,现总结一下:

(1) Unity3D的二进制资源必须加锁进行版本控制,因为它没办法merge;

(2) Unity3D自己产生的C#工程相关文件,包括VS产生或者Mono产生的,都不需要归入版本控制;

(3) 在新加入项时,Unity3D会产生一个同名的.meta文件,这个文件记录了此项一个唯一的64位的guid,这个文件必须上传,否则会出现各种缺失的异常情况(比如脚本Miss等)

(4) 对于ProjectSettings文件夹,有以下几个.Asset文件需要进行版本管理:

               TimeManager

               TagManager

               QualitySettings

               ProjectSettings

               NetworkManager

               InputManager

               EditorBuildSettings

               DynamicsManager

               AudioManager

即便如此,在使用Editor进行开发时,由于需要经常改动场景的.unity 文件,而这个是二进制的,所以需要得锁且不能Merge。感觉并行开发的难度还是比较大的,Unity3D还是比较适合个人开发者和较小团队开发,对于大型团队开发,无论是从版本管理还是代码结构上,都觉得不太方便和自然。


Unity3D - 导入/导出Package功能和项目管理的研究


本文摘要

       本文首先描述了Unity3.0在支持大型游戏项目开发时的两个不足:即对模块化和svn协同缺乏支持。随后,分析了Unity自带的Export/Import Package 功能,并提出了使用此功能与svn配合实现多人项目协同的方法。 

Unity项目协同的挑战


     在使用Unity开发游戏项目时,一般都需要多人同时工作。例如每人负责不同的场景,或者一些人负责调试光照和渲染,另一些负责编写程序逻辑。总之一个人全包的情况对于稍大一点的项目而言少之又少。但遗憾的是Unity对协同项目工作和大型项目的支持可以用糟糕来形容。 
     首先,Unity没有模块化开发的概念。我们知道模块化是开发大型项目必须的一种实践方法。例如用VC开发大型程序时,我们可以把程序拆分成多个dll项目来开发,由此减少单个项目的复杂度和编译时间。另一个例子是flash程序的开发,同样可以把工作拆分成多个flash项目,最后将每个项目生成的swf或者swc合在一起工作。 
     然而到目前的3.0版本为止,Unity仍然不支持类似dll或者swc/swf这种模块化构建应用程序的方法。对Unity而言,一个游戏就是一个工程。如果游戏规模很大,包含很多资源,那么项目就不可避免地变得臃肿和难以维护。Unity在打开、刷新、编译这类工程时也会耗用更多的时间。以至于在Unity官方论坛上都能看到许多这方面的抱怨。例如这篇帖子http://answers.unity3d.com/questions/19688/splitting-complex-project-into-multiple-projects就详细地描述了一个770M左右大小的项目所面临的困境。 
      其次,Unity会将项目信息以二进制格式保存在library目录中,其中被称为元数据(Meta Data)的信息更是记录了构成游戏的许多关键数据(例如模型导入所使用的各项设置、Asset之间的引用关系等)。但由于这些数据是二进制格式,并且存放方式很不清晰,因此在使用SVN等版本管理系统时,无法采取多人修改-合并的方式。只能一个人改完后,提交整个项目,然后下一个人再改。严重阻碍了项目协同。Unity官方提供了一个收费的AssetServer,我没有用过,不知能否解决这个问题。如果我们能通过一些手段让免费的svn发挥作用,何乐而不为呢? 
      对于Unity的第一个缺点,我们暂时没有好的办法来解决,只能希望Unity后续的版本能提供模块化的支持。(Unity和ExitGame近期宣布展开合作,推出一款针对MMOG开发的产品组合。Unity将推出一个叫Legion的版本,与ExitGame的Photon配合。我猜测Legion应该对大型游戏项目要支持得更好些吧。) 
      至于第二个缺点,我们可以用Unity的输出/导入包(Export/Import Package)功能,配合svn在一定程度上加以解决。 

用“输出/导入包(Export/Import Package)”功能实现项目协同


Unity的Export/Import Package功能主要用途是在不同的项目之间实现asset复用。该功能的基本介绍和操作详见官方文档,本文将进一步描述该功能的具体表现,以及如何利用该功能实现多人项目的协作。 
导入导出包功能具有下列特性:  
  • 在导出时,Unity会记录导出内容在项目中的完整路径,并在导入时重建对应的目录结构。因此我们可以方便地在项目间同步目录。  
  • 导出时,Unity会让你选择是否导出被依赖的内容。如果钩选择会自动添加被依赖的内容,并显示在列表中。如下图。
[attachment=14]
不导出依赖
[attachment=15]
导出依赖
  • 导入时,Unity会判断当前项目中是否存在名称、路径完全相同的文件。若有,则判断修改时间是否一致,若一致就忽略,否则会提示是否覆盖。注意Unity并不管文件的新旧,只是简单地询问用户是否用包中的文件覆盖项目中的同名文件。如下图:
[attachment=16]

  
  • 最重要的是,Unity输出包时,还包含了asset对应的元数据。用WinRAR或者其他压缩软件打开Unity导出的.unitypackage文件,就可以看到这些元数据文件,如下图:
[attachment=17]

      正是由于导出的包自动包含了相关元数据信息,弥补了用SVN无法管理这些数据的缺陷,我们就可以将二者配合使用,达到多人在一个项目中协同工作的效果。具体建议如下:
  1. 首先用SVN建立对整个项目文件夹的管理,包括asset和library目录以及下面的文件;
  2. 由负责集成的项目组成员管理并提交该项目更新到svn数据库
  3. 其他协作人员从svn数据库下载最新的项目文件
  4. 协作人员对自己负责的内容进行工作,然后将成果输出。输出时不要钩选依赖
  5. 将输出的unitypackage文件提交给集成人员(通过svn或者其他途径都可以)
  6. 集成人员将新的unitypackage导入项目,然后再提交到svn数据库

       如果对人员分工、规范以及项目目录规划得好的话,采用这种方式完全可以实现多人同时工作,提高项目开发和迭代的效率。

Using External Version Control Systems with Unity

Unity offers an Asset Server add-on product for easy integrated versioning of your projects. If you for some reason are not able use the Unity Asset Server, it is possible to store your project in any other version control system, such as Subversion, Perforce or Bazaar. This requires some initial manual setup of your project. In addition, moving and renaming of assets needs to be performed using your version control client and not inside Unity.

External Version Control is available in all versions of Unity.

Before checking your project in, you have to tell Unity to modify the project structure slightly to make it compatible with storing assets in an external version control system. This is done by selecting Edit->Project Settings->Editor in the application menu and enabling External Version Control support by selectingMetafiles in the dropdown for Version Control. This will create a text file for every asset in the Assets directory containing the necessary bookkeeping information required by Unity. The files will have a .meta file extension with the first part being the full file name of the asset it is associated with. When moving or renaming assets in the version control system, make sure you also move or rename the .meta file accordingly.

When checking the project into a version control system, you should add the Assets and the ProjectSettings directories to the system. The Librarydirectory should be completely ignored - when using external version control, it's only a local cache of imported assets.

When creating new assets, make sure both the asset itself and the associated .meta file is added to version control.

Example: Creating a new project and importing it to a Subversion repository.

First, let's assume that we have a subversion repository at svn://my.svn.server.com/ and want to create a project atsvn://my.svn.server.com/MyUnityProject. Then follow these steps to create the initial import in the system:

  1. Create a new project inside Unity and lets call it InitialUnityProject. You can add any initial assets here or add them later on.
  2. Enable Meta files in Edit->Project Settings->Editor
  3. Quit Unity (We do this to assure that all the files are saved).
  4. Delete the Library directory inside your project directory.
  5. Import the project directory into Subversion. If you are using the command line client, this is done like this from the directory where your initial project is located:
    svn import -m"Initial project import" InitialUnityProject svn://my.svn.server.com/MyUnityProject
    If successful, the project should now be imported into subversion and you can delete the InitialUnityProject directory if you wish.
  6. Check out the project back from subversion
    svn co svn://my.svn.server.com/MyUnityProject
    And check that the Assets and ProjectSettings directory are versioned.
  7. Open the checked out project with Unity by launching it while holding down the Option or the left Alt key. Opening the project will recreate the Librarydirectory in step 4 above.
  8. Optional: Set up an ignore filter for the unversioned Library directory:
    svn propedit svn:ignore MyUnityProject/
    Subversion will open a text editor. Add the Library directory.
  9. Finally commit the changes. The project should now be set up and ready:

  1. svn ci -m"Finishing project import" MyUnityProject
转载:http://blog.csdn.net/programmerboymxd/article/details/7342348

0 0
原创粉丝点击