【轉】全面解析Unity3D自動產生的指令碼工程檔案

來源:互聯網
上載者:User

標籤:amp   src   icon   疑惑   blog   core   unity3d   ptr   gen   

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

 

我們在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檔案,並且先編譯;

(2) 所有在Standard Assets/Editor, Pro Standard Assets/Editor 或這Plugins/Editor檔案夾中的指令碼產生Assembly-CSharp-Editor-firstpass-vs.csproj工程,接著編譯;

 

(3) 所有在Assets/Editor外面的, 並且不在(1),(2)中的指令檔(一般這些指令碼就是我們自己寫的非編輯器擴充的指令碼)會產生Assembly-CSharp-vs.csproj工程,被編譯;

(4) 所以在Assets/Editor中的指令碼產生一個Assembly-CSharp-Editor-vs.csproj工程,被編譯。

之所有這樣建立工程並按此順序編譯,也是因為DLL間存在的依賴關係所決定的。

 

好了,至此也說得比較清楚了,也不會因為見到那麼多的工程檔案而疑惑了。

最後問諸位一個小問題:

一個Unity3D的工程,最多可以產生多少個工程檔案?

4*3*2 = 24個

 

 

 

 

Why is the unity folder so cluttered with IDE files

Whenever I create a new Unity project, add a C# script file and synchronize it with an external source code editor, there appears a number of .sln and .csproj files generated in the main project folder.

I wouldn‘t bother it wasn‘t for the fact that there‘s 6 x .csproj and 2 x .sln with names like:

  • Assembly-CSharp.csproj

  • Assembly-CSharp-Editor.csproj

  • Assembly-CSharp-Editor-vs.csproj

  • Assembly-CSharp-firstpass.csproj

  • Assembly-CSharp-firstpass-vs.csproj

  • Assembly-CSharp-vs.csproj

After a solution is opened automatically by Unity, it has 3 projects with pretty similar structure - every project has an Assets folder, but seems to include a different permutation of assets.

Whether I use VS or MonoDevelop doesn‘t matter. The question is:

Is this a standard project structure or did I get something wrong? Is it possible to reduce the clutter, which makes me unsure which project I should be working on, or are all these files necessary?

The reason I‘m asking is there seems to be a lot of redundancy and it‘s not very clear what each of these projects is responsible for.

 評論  1條回複
  • 排序: 
3最佳解答

個解答,截止stevethorne · 2014年05月02日 13:26

This is the standard solution structure for a Unity project. Each one can have a number of projects in the solution. Mine usually have 6 projects in the solution. You didn‘t do anything wrong, and there‘s nothing you can do to reduce this. These are needed for both unity and the IDE that you‘re using.

If you‘re wondering why they do this, it‘s due to the fact that they need to make sure that things get compiled in the correct order. You can take a look at this page for more details on the compile order. That might also help you understand what‘s put in each project.

For those not wanting to go searching for what‘s in each project, here‘s a basic synopsis:

Assembly-CSharp-firstpass.csproj

  • contains the files in the StandardAssets folder.

Assembly-CSharp.csproj

  • contains the files outside of the Editor folder.

Assembly-CSharp-Editor.csproj

  • contains the files inside of the Editor folder.

The projects that replace "CSharp" with "UnityScript" contain the Unity Script files in the same manner.

As for the ones ending in -vs, I‘d imagine those are for the visual studio projects.

 

【轉】全面解析Unity3D自動產生的指令碼工程檔案

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.