Unity默认目录(中英文对照)

来源:互联网 发布:meta分析怎么提取数据 编辑:程序博客网 时间:2024/06/04 20:32

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

    0 0