Unity默認目錄(中英文對照)

Hidden Folders

Folders that start with a dot (e.g. “.UnitTests/”, “.svn/”) are ignored by Unity. Any assets in there are not imported, and any scripts in there are not compiled. They will not show up in the Project view.

以”.“(例如: “.UnityTests/”,”.svn/” )開頭的文件夾會被Unity忽略。在這種文件夾中的資源不會被導入,腳本不會被編譯。也不會出現在Project視圖中。


Standard Assets

Scripts in here are always compiled first. Scripts are output to either Assembly-CSharp-firstpass, Assembly-UnityScript-firstpass, or Assembly-Boo-firstpass, depending on the language. See http://docs.unity3d.com/Documentation/Manual/ScriptCompileOrderFolders.html
Scripts inside the Standard Assets folder will be compiled earlier than your other scripts. So, placing scripts in Standard Assets is one way for C# scripts to be able to access .js scripts or vice-versa.

在這個文件夾中的腳本最先被編譯。 這個文件夾中的腳本會被導出到Assembly-CSharp-firstpass, Assembly-UnityScript-firstpass 或 Assembly-Boo-firstpass項目中,依語言而定。在這個文件夾中的腳本比其他腳本都要先編譯。將腳本放在這個文件夾裏,就可以用C#腳本來訪問js腳本或其他語言的腳本。


Pro Standard Assets

Same with Standard Assets, only files here are meant for the Pro version. This means assets here make use of Pro-only features like render textures and screen-space effects.
Again, scripts here are compiled earlier, allowing them to be accessed by other scripts (of any language) that are outside the Pro Standard Assets folder.

跟Standard Assets相同,只不過裏面的文件是給Pro版本的Unity使用的。


Editor

The Editor folder name is a special name which allows your scripts access to the Unity Editor Scripting API. If your script uses any classes or functionality from the UnityEditor namespace, it has to be placed in a folder called Editor.
Scripts inside an Editor folder will not be included in your game’s build. They are only used in the Unity Editor.
You can have multiple Editor folders throughout your project.
Note: An Editor folder not located in another special folder can be placed/nested anywhere in the project. However, if it’s in “Standard Assets”, “Pro Standard Assets”, or “Plugins”, it must be a direct child of these folders. Otherwise, it will not get processed. For example, it’s ok to have a path like “My Extension/Scripts/Editor”, but if placed in a special folder, it must always be “Standard Assets/Editor/My Extension/Scripts”, or “Pro Standard Assets/Editor/My Extension/Scripts”, or “Plugins/Editor/My Extension/Scripts”.

以Editor命名的文件夾允許其中的腳本訪問Unity Editor的API。如果腳本中使用了在UnityEditor命名空間中的類或方法,它必須被放在名爲Editor的文件夾中。Editor文件夾中的腳本不會在build時被包含。
在項目中可以有多個Editor文件夾。
注意:如果在普通的文件夾下,Editor文件夾可以處於目錄的任何層級。如果在特殊文件夾下,那Editor文件夾必須是特殊文件夾的直接子目錄。


Plugins

The “Plugins” folder is where you must put any native plugins, which you want to be accessible by your scripts. They will also be automatically included in your build. Take note that this folder may not be in any subfolder (it has to reside within the top-level Assets folder).
In Windows, native plugins exist as .dll files, in Mac OS X, they are .bundle files, and in Linux, they are .so files.
Like the Standard Assets folder, any scripts in here are compiled earlier, allowing them to be accessed by other scripts (of any language) that are outside the Plugins folder.

Plugins文件夾用來放native插件。它們會被自動包含進build中去。注意這個文件夾只能是Assets文件夾的直接子目錄。
在Windows平臺下,native 插件是dll文件;Mac OS X下,是bundle文件;Linux下,是.so文件。
跟Standard Assets一樣,這裏的腳本會更早的編譯,允許它們被之外的腳本訪問。


  • Plugins/x86

If you are building for 32-bit or a universal (both 32 and 64 bit) platform, and if this subfolder exists, any native plugin files in this folder will automatically be included in your build. If this folder does not exist, Unity will look for native plugins inside the parent Plugins folder instead.

如果爲32bit或64bit平臺創建遊戲,那麼這個文件夾下的native plugin文件會被自動的包含在遊戲build中。如果這個文件夾不存在,則Unity會查找Plugins文件夾下的native pluglins。

  • Plugins/x86_64

    If you are building for 64-bit or a universal (both 32 and 64 bit) platform, and if this subfolder exists, any native plugin files in this folder will automatically be included in your build. If this folder does not exist, Unity will look for native plugins inside the parent Plugins folder instead.
    If you are making a universal build, it’s recommended you make both the x86 and x86_64 subfolders. Then have the 32-bit and 64-bit versions of your native plugins in the proper subfolder correspondingly.

    如果爲32bit或64bit平臺創建遊戲,那麼這個文件夾下的native plugin文件會被自動的包含在遊戲build中。如果這個文件夾不存在,則Unity會查找Plugins文件夾下的native pluglins。
    如果要創建universal build,建議你同時使用這兩個文件夾。然後將32bit和64bit的native plugins放進相應的文件夾中。

  • Plugins/Android

    Place here any Java .jar files you want included in your Android project, used for Java-based plugins. Any .so file (when having Android NDK-based plugins) will also be included. See http://docs.unity3d.com/Documentation/Manual/PluginsForAndroid.html

    在這個文件夾裏放入Java.jar文件。用於java語言的plugins。.so文件也會被包含進來。

  • Plugins/iOS

    A limited, simple way to automatically add (as symbolic links) any .a, .m, .mm, .c, or .cpp files into the generated Xcode project. Seehttp://docs.unity3d.com/Documentation/Manual/PluginsForIOS.html
    If you need more control how to automatically add files to the Xcode project, you should make use of the PostprocessBuildPlayer feature. Doing so does not require you to place such files in the Plugins/iOS folder. Seehttp://docs.unity3d.com/Documentation/Manual/BuildPlayerPipeline.html

    一種有限制的,簡單的自動添加任何 .a .m .mm .c .cpp文件到產生的Xcode工程的方法,如果你需要更多的控制如何自動的添加文件到Xcode工程,你應該確保 PostprocessBuildPlayer特性,這樣做不需要你放置這樣的文件到Plugins/IOS文件夾。


  • Resources

    The Resources folder is a special folder which allows you to access assets by file path and name in your scripts, rather than by the usual (and recommended) method of direct references (as variables in scripts, wherein you use drag-and-drop in the Unity Editor).
    For this reason, caution is advised when using it. All assets you put in the Resources folder are always included in your build (even if it turned out that they are unused), because, since you are using them via scripts, Unity then has no way of determining which Resources-based assets are used or not.
    You can have multiple Resources folders throughout your project, so it is not recommended to have an asset in one Resources folder and have another asset with that same name in another Resources folder.
    Once your game is built, all assets in all Resources folders get packed into the game’s archive for assets. This means the Resources folder technically doesn’t exist anymore in your final build, even though your code will still access them via the paths that existed while it was in your project.
    Also see http://docs.unity3d.com/Documentation/Manual/LoadingResourcesatRuntime.html
    Take note when assets are accessed as variables of MonoBehaviour scripts, those assets get loaded into memory once that MonoBehaviour script is instantiated (i.e. its game object or prefab is now in the scene). This may be undesirable, if the asset is too large and you want more control of when it gets loaded into memory.
    Consider putting such large assets in a Resources folder, and load them via Resources.Load. When not used anymore, you can free the memory it took up by calling Object.Destroy on the object, followed by Resources.UnloadUnusedAssets.

    Resources文件夾允許你在腳本中通過文件路徑和名稱來訪問資源。但還是推薦使用直接引用來訪問資源。
    放在這一文件夾的資源永遠被包含進build中,即使它沒有被使用。因爲Unity無法判斷腳本有沒有訪問了其中的資源。 項目中可以有多個Resources文件夾,因此不建議在多個文件夾中放同名的資源。 一旦build遊戲,Resources文件夾中的所有資源被打包進遊戲存放資源的archive中。這樣在遊戲的build中就不存在Resources文件夾了。即使腳本中仍然使用了資源在項目中的路徑.
    注意:當資源作爲腳本變量被訪問時,這些資源在腳本被實例化後就被加載進內存。如果資源太大,你可能不希望它被這樣加載。那麼你可以將這些大資源放進Resources文件夾中,通過Resources.Load來加載。當不再使用這些資源了,可以通過Destroy物體,再調用Resources.UnloadUnusedAssets來釋放內存。

    注:可以在根目錄下,也可以在子目錄裏,只要名子叫Resources就可以。比如目錄:/xxx/xxx/Resources 和 /Resources 是一樣的,無論多少個叫Resources的文件夾都可以。Resources文件夾下的資源不管你用還是不用都會被打包進.apk或者.ipa

    Resource.Load :編輯時和運行時都可以通過Resource.Load來直接讀取

    AssetDatabase.LoadAssetAtPath():它可以讀取Assets目錄下的任意文件夾下的資源,它只能在編輯時用。它的路徑是”Assets/xx/xx.xxx” 必須是這種路徑,並且要帶文件的後綴名。

    覺得在電腦上開發的時候儘量來用Resource.Load() 或者 Resources.LoadAssetAtPath() ,假如手機上選擇一部分資源要打assetbundle,一部分資源Resource.Load().那麼在做.apk或者.ipa的時候 現在都是用腳本來自動化打包,在打包之前 可以用AssetDatabase.MoveAsset()把已經打包成assetbundle的原始文件從Resources文件夾下移動出去在打包,這樣打出來的運行包就不會包行多餘的文件了。打完包以後再把移動出去的文件夾移動回來。


    Editor Default Resources

    This folder functions like a Resources folder, but is meant for editor scripts only. Use this if your editor plugin needs to load assets (e.g. icons, GUI skins, etc.) while making sure said assets won’t get included in the user’s build (putting such files in a normal Resources folder would have meant that those assets would be included in the user’s game when built).
    As editor scripts aren’t MonoBehaviour scripts, you can’t do the usual way of accessing assets (i.e. dragging-and-dropping via the Inspector). The “Editor Default Resources” is for a convenient way around this.
    To access assets inside the “Editor Default Resources”, you need to use EditorGUIUtility.Load.
    Take note that unlike Resources.Load, EditorGUIUtility.Load requires you to specify the filename extension of the asset you’re trying to load. So it has to be “myPlugin/mySkin.guiskin” instead of “myPlugin/mySkin”.
    To free memory used by EditorGUIUtility.Load, call Object.Destroy on the object, then call EditorUtility.UnloadUnusedAssets.
    Afaik, only one “Editor Default Resources” folder can be present, and it has to be directly under the top Assets folder.

    Editor Default Resources注意中間是有空格的,它必須放在Project視圖的根目錄下,如果你想放在/xxx/xxx/Editor Default Resources 這樣是不行的。你可以把編輯器用到的一些資源放在這裏,比如圖片、文本文件、等等。它和Editor文件夾一樣都不會被打到最終發佈包裏,僅僅用於開發時使用。你可以直接通過EditorGUIUtility.Load去讀取該文件夾下的資源。

    TextAsset text =    EditorGUIUtility.Load("test.txt")as TextAsset;
            Debug.Log(text.text);

    Gizmos

    The gizmos folder holds all the texture/icon assets for use with Gizmos.DrawIcon. Texture assets placed inside this folder can be called by name, and drawn on-screen as a gizmo in the editor.

    Gizmos文件夾存放用Gizmos.DrawIcon方法使用的貼圖、圖標資源。放在Gizmos文件夾中的貼圖資源可以直接通過名稱使用,可以被Editor作爲gizmo畫在屏幕上。


    WebPlayerTemplates

    Used to replace the default web page used for web builds. Any scripts placed here will not be compiled at all. This folder has to be in your top-level Assets folder (it should not be in any subfolder in your Assets directory).

    用來替換web build的默認網頁。這個文件夾中的腳本都不會被編譯。這個文件夾必須作爲Assets文件夾的直接子目錄。


    StreamingAssets

    Any files in here are copied to the build folder as is, without any changes (except for mobile and web builds, where they get embedded into the final build file). The path where they are can vary per platform but is accessible via Application.streamingAssetsPath (http://docs.unity3d.com/Documentation/ScriptReference/Application-streamingAssetsPath.html) Also see http://docs.unity3d.com/Documentation/Manual/StreamingAssets.html
    The location of this folder varies per platform. Please note that these are case-sensitive:
    On a desktop computer (Mac OS or Windows) the location of the files can be obtained with the following code:
    path = Application.dataPath + "/StreamingAssets";
    On iOS, use:
    path = Application.dataPath + "/Raw";
    On Android, use:
    path = "jar:file://" + Application.dataPath + "!/assets/";

    這裏的文件會被拷貝到build文件夾中,不會修改(移動和網頁版不同,他們會被嵌入到最終build文件中)。它們的路徑會因平臺而有差異,但都可以通過Application.streamingAssetsPath來訪問。
    不同的平臺訪問的方式不同,請注意:


    • 在PC上訪問路徑:
      path = Application.dataPath + "/StreamingAssets";
    • IOS上訪問路徑:
      path = Application.dataPath + "/Raw";
    • Andriod上訪問路徑:
      path = "jar:file://" + Application.dataPath + "!/assets/";

    注:這個文件夾下的資源也會全都打包在.apk或者.ipa 它和Resources的區別是,Resources會壓縮文件,但是它不會壓縮原封不動的打包進去。並且它是一個只讀的文件夾,就是程序運行時只能讀 不能寫。它在各個平臺下的路徑是不同的,不過你可以用Application.streamingAssetsPath 它會根據當前的平臺選擇對應的路徑。

    因爲Application.persistentDataPath目錄是應用程序的沙盒目錄,所以打包之前是沒有這個目錄的,直到應用程序在手機上安裝完畢纔有這個目錄。

    StreamingAssets目錄下的資源都是不壓縮的,所以它比較大會佔空間,比如你的應用裝在手機上會佔用100M的容量,那麼你又在StreamingAssets放了一個100M的assetbundle,那麼此時在裝在手機上就會在200M的容量。

    參考網址:

    http://wiki.unity3d.com/index.php/Special_Folder_Names_in_your_Assets_Folder
    https://www.douban.com/group/topic/59120314/
    http://www.xuanyusong.com/archives/3229

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