AssetPostprocessor 资源处理器

ssetPostprocessor lets you hook into the import pipeline and run scripts prior or after importing assets.

AssetPostprocessor让你钩进导入管线,在运行脚本之前或导入资源之后。

Note: This is an editor class. To use it you have to place your script in Assets/Editor inside your project folder. Editor classes are in the UnityEditor namespace so for C# scripts you need to add "using UnityEditor;" at the beginning of the script.
注意:这是一个编辑器类,如果想使用它你需要把它放到工程目录下的Assets/Editor文件夹下。编辑器类在UnityEditor命名空间下。所以当使用C#脚本时,你需要在脚本前面加上 "using UnityEditor"引用。

This way you can override default values in the import settings or modify the imported data like textures or meshes.

这样你可以在导入的设置中重载默认值或修改导入的数据,如纹理或网格。

Variables变量

  • assetPath

    The path name of the asset being imported.
    被导入的资源的路径名

  • assetImporter

    Reference to the asset importer
    引用资源导入器

Functions函数

  • LogWarning

    Logs an import warning to the console.
    记录一个导入警告到控制台

  • LogError

    Logs an import error message to the console.
    记录一个导入错误消息到控制台

  • GetPostprocessOrder

    Override the order in which importers are processed.
    重载导入器执行的次序

Messages Sent发送消息

  • OnPreprocessTexture

    Add this function in a subclass to get a notification just before the texture importer is run.
    在子类中重载这个函数以便在纹理导入器运行之前获取通知

  • OnPostprocessTexture

    Add this function in a subclass to get a notification when a texture has completed importing just before the texture is saved to disk.
    在子类中加入这个函数,以便在纹理载入存入磁盘之前获得一个通知。

  • OnPreprocessModel

    Add this function in a subclass to get a notification just before a model (.fbx, .mb file etc.) is being imported.
    在子类中加入这个函数,以便在模型载入之前获得一个通知。

  • OnPostprocessModel

    Add this function in a subclass to get a notification when a model has completed importing
    在子类中加入这个函数,以便在模型载入之后获得一个通知。

  • OnPostprocessGameObjectW...

    Gets called for each GameObject that had at least one userpropery attached to it in the imported file.
    在导入文件中,为每个至少附加了一个用户属性的游戏物体调用。

  • OnAssignMaterialModel

    Feeds a source material
    获取一个源材质

  • OnPostprocessAudio

    Add this function in a subclass to get a notification when an audio clip has completed importing.
    在子类中加入这个函数,以便在一个声音剪辑载入后获得一个通知。

  • OnPreprocessAudio

    Add this function in a subclass to get a notification just before an audio clip is being imported.
    在子类中加入这个函数,以便在一个声音剪辑载入之前获得一个通知。

  • OnPostprocessAllAssets

    This is called after importing of any number of assets is complete (when the Assets progress bar has reached the end).
    在一些资源被导入后调用(当资源进度条到达末端)

  •  
  • 原文地址:http://www.ceeger.com/Script/AssetPostprocessor/AssetPostprocessor.html

在Unity中,可以通过手动创建文件夹或通过脚本自动创建文件夹。 手动创建文件夹可以通过在Unity的Project视图中右键点击选择"Create"然后选择"Folder"来创建文件夹。你可以选择在Assets文件夹下创建文件夹,也可以在其他文件夹下创建文件夹。此外,还有一些特殊文件夹,如Resources文件夹用于存储需要在运行时动态加载的资源,StreamingAssets文件夹用于存储需要和应用程序一起打包的数据,Plugins文件夹用于存储第三方插件或库。 如果你想要在导入资源包的时候自动创建文件夹,你可以使用脚本来实现。在Assets/Scripts/Editor文件夹下创建一个脚本,并命名为AutoCreateFloder.cs。在这个脚本中,你可以使用Unity的AssetPostprocessor类,在OnPostprocessAllAssets方法中监听导入资源的事件,并在事件触发时创建文件夹。这个脚本可以参考以下代码: ``` using System.Collections; using System.Collections.Generic; using UnityEditor; using UnityEngine; public class AutoCreateFloder : AssetPostprocessor { static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { foreach (string s in importedAssets) { if (s.Equals("Assets/Scripts/Editor/AutoCreateFloder.cs")) { CreateProjectFloder.CreatAllProjectFolder(); return; } } } } ``` 这段代码会在导入资源时检查导入的资源路径,如果路径匹配到了脚本的路径,则调用CreateProjectFloder.CreatAllProjectFolder()方法来创建文件夹。你可以根据自己的需求修改脚本中的方法以及文件夹的创建逻辑。 总结起来,Unity创建文件夹可以通过手动创建或使用脚本自动创建。手动创建可以通过在Project视图中右键点击选择"Create"然后选择"Folder"来创建文件夹,也可以创建一些特殊文件夹如Resources、StreamingAssets和Plugins。自动创建文件夹可以通过编写一个脚本,在AssetPostprocessor的OnPostprocessAllAssets方法中监听导入资源事件,并在事件触发时创建文件夹。以上就是Unity创建文件夹的方法。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [【Unity3D小功能】Unity3D中在创建完项目后自动创建文件夹列表](https://blog.csdn.net/q764424567/article/details/129662252)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值