白泽图

  • 文章
    • Unity渲染
    • Unity项目开发
    • 工具
    • 数学
    • 算法
    • 网站搭建
    • 网络&操作系统
蒋程个人博客
互联网技术经验总结&分享
  1. 首页
  2. Unity项目开发
  3. 正文

unity 资源导入管线 AssetPostprocessor

2022-01-09 625点热度 0人点赞 0条评论

可以监听Unity Project面板下,所有资源的变化(导入,删除,重载)

using UnityEngine;
using UnityEditor;

class MyAllPostprocessor : AssetPostprocessor
{
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        foreach (string str in importedAssets)
        {
            Debug.Log("Reimported Asset: " + str);
        }
        foreach (string str in deletedAssets)
        {
            Debug.Log("Deleted Asset: " + str);
        }

        for (int i = 0; i < movedAssets.Length; i++)
        {
            Debug.Log("Moved Asset: " + movedAssets[i] + " from: " + movedFromAssetPaths[i]);
        }
    }
}

也可以只关注制定类型资源的导入如

void OnPostprocessModel(GameObject g)
    {
       
    }

API地址 :https://docs.unity3d.com/2019.4/Documentation/ScriptReference/AssetPostprocessor.html

依赖此接口可以制作 资源导入后自动检查纠错 等相关工具

标签: 暂无
最后更新:2022-01-09

蒋程

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

您需要 登录 之后才可以评论

COPYRIGHT © 2023 白泽图. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

登录
注册|忘记密码?