unity 工程编译顺序

我们在Unity3D开发的时候,经常会看到它会产生不少固定命名工程文件,诸如:

Assembly-CSharp-vs.csproj 

Assembly-CSharp-firstpass-vs.csproj

Assembly-CSharp-Editor-vs.csproj

Assembly-CSharp-Editor-firstpass-vs.csproj

看得不少人云里雾里的。那么,这些工程是如何产生的呢?各自的作用是什么?下面就来逐一解析。

一. 首先从脚本语言类型来看,Unity3D支持3种脚本语言,都会被编译成CLI的DLL

如果应用中含有C#脚本,那么Unity3D会产生以Assembly-CSharp为前缀的工程,名字中包含"vs的"是产生给Visual Studio使用的,不包含"vs"的是产生给MonoDevelop用的。

应用中包含的脚本语言

工程前缀

工程后缀

C#

Assembly-CSharp

csproj

JavaScript

Assembly-UnityScript

unityproj

Boo

Assembly-Boo

booproj


如果工程中这3中脚本都存在,那么Unity3D将会生成3种前缀类型的工程。

 

二. 对于每一种脚本语言,根据脚本放置的位置(其实也部分根据了脚本的作用,比如编辑器扩展脚本,就必须放在Editor文件夹下),Unity3D会生成4种后缀的工程。其中的firstPass就表示先编译,Editor表示放在Editor文件夹下的脚本。

下面以C#脚本为例。如果工程中只有C#脚本,不考虑为VS和MonoDevelop各自生成工程的差异性,我们可以得到4个工程文件:

Assembly-CSharp-firstpass-vs.csproj

Assembly-CSharp-Editor-firstpass-vs.csproj

Assembly-CSharp-vs.csproj 

Assembly-CSharp-Editor-vs.csproj

(1) 所有在Standard Assets,Pro Standard Assets或者 Plugins文件夹中的脚本会产生一个Assembly-CSharp-firstpass-vs.csproj文件,并且先编译;

Standard Assets Assembly-CSharp-firstpass.dll
Pro Standard Assets
Plugins【排除Plugins/Editor】

(2) 所有在Standard Assets/Editor, Pro Standard Assets/Editor 或这Plugins/Editor文件夹中的脚本产生Assembly-CSharp-Editor-firstpass-vs.csproj工程,接着编译;

Standard Assets/Editor Assembly-CSharp-Editor-firstpass.dll
Pro Standard Assets/Editor
Plugins/Editor

(3) 所有在Assets/Editor外面的, 并且不在(1),(2)中的脚本文件(一般这些脚本就是我们自己写的非编辑器扩展的脚本)会产生Assembly-CSharp-vs.csproj工程,被编译;

排除Assets/Editor Assembly-CSharp.dll
排除(1)
排除(2)

(4) 所以在Assets/Editor中的脚本产生一个Assembly-CSharp-Editor-vs.csproj工程,被编译。

Assets/Editor Assembly-CSharp-Editor.dll

之所有这样建立工程并按此顺序编译,也是因为DLL间存在的依赖关系所决定的。

 

转http://blog.csdn.net/jjiss318/article/details/7632041

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章