惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Troy Hunt's Blog
P
Palo Alto Networks Blog
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
Threatpost
C
Cyber Attacks, Cyber Crime and Cyber Security
S
Schneier on Security
Google Online Security Blog
Google Online Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Spread Privacy
Spread Privacy
NISL@THU
NISL@THU
Cisco Talos Blog
Cisco Talos Blog
The GitHub Blog
The GitHub Blog
S
SegmentFault 最新的问题
量子位
L
Lohrmann on Cybersecurity
酷 壳 – CoolShell
酷 壳 – CoolShell
Attack and Defense Labs
Attack and Defense Labs
Y
Y Combinator Blog
Project Zero
Project Zero
AWS News Blog
AWS News Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
博客园 - 聂微东
MyScale Blog
MyScale Blog
aimingoo的专栏
aimingoo的专栏
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
Securelist
Latest news
Latest news
C
CXSECURITY Database RSS Feed - CXSecurity.com
B
Blog RSS Feed
Webroot Blog
Webroot Blog
Blog — PlanetScale
Blog — PlanetScale
Recent Announcements
Recent Announcements
V2EX - 技术
V2EX - 技术
Schneier on Security
Schneier on Security
F
Full Disclosure
Apple Machine Learning Research
Apple Machine Learning Research
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
P
Proofpoint News Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
月光博客
月光博客
L
LINUX DO - 最新话题
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
H
Heimdal Security Blog
F
Fortinet All Blogs
博客园_首页
N
News | PayPal Newsroom
P
Proofpoint News Feed

博客园 - 野生西瓜

[Unity 杂货铺] SpriteAtlas 和 SBP 打包 [Unity 杂货铺] 游戏字体选择 [Unity 杂货铺] 游戏项目的结构规划与初始化 [Unity 杂货铺] Git 配置与实践 [Unity 杂货铺] 引擎版本的选择 [Unity] 基础寻路算法 - 环境搭建 [Unity] 引擎脚本相关的字符串优化 [Unity] 基础寻路算法 - 代码实践 [Unity] 资源工作流程 - AssetPostprocessor [Unity] 资源工作流程 - ScriptedImporter [Lua游戏AI开发指南] 笔记零 - 框架搭建 [GAME] [Civilization] 文明6字体及字体大小修改 [Unity] 编辑器运行中动态编译执行C#代码 [Unity] 在软件标题栏显示工作路径 [GAMEDEV] 个人开发如何找到合适的图片素材? [施工中] 博客导航 2021 的书 [BACKUP] Visual Studio Code 配置 [theHunterCOTW] 猎人荒野的召唤-一点资料
[Unity] 资源工作流程 - 辅助工具
野生西瓜 · 2022-04-01 · via 博客园 - 野生西瓜

一、前言

备忘用,内容较杂

二、项目资源检查

(一)资源 Importer 属性检查

  1. AssetImporter.GetAtPath
    https://docs.unity.cn/cn/2021.2/ScriptReference/AssetImporter.GetAtPath.html
  2. TextureImporter
    https://docs.unity.cn/cn/2021.2/ScriptReference/TextureImporter.html
// 项目资源 Importer 属性检查
[MenuItem("资源检查/查询开启 Read/Write 的图片")]
static void TextureCheck()
{
    string[] paths = AssetDatabase.GetAllAssetPaths();
    for (int i = 0; i < paths.Length; i++)
    {
        AssetImporter importer = AssetImporter.GetAtPath(paths[i]);
        TextureImporter textureImporter = importer as TextureImporter;
        if (textureImporter && textureImporter.isReadable)
        {
            Debug.Log(paths[i]);
        }
    }
}

(二)获取资源在 Library 目录下的位置

参考自:https://gist.github.com/Unity-Javier/50408443ddda2f64d029eb3a5e71cfe4

Unity 使用 .meta 文件来保存资源的唯一识别码和各种配置属性。

Library 目录,是已导入资源的本地缓存位置,项目 Assets 中的资源主要缓存在 Library\Artifacts 中,按 Hash 值划分目录。

使用版本控制系统时,应该忽略 Library 和 UserSettings 目录。但要确保资源导入器在导入时会产生一致的结果。

可以使用‘binary2text’工具(位于 Unity 编辑器安装位置下的 Data/Tools 文件夹中)检查 Library 文件夹的内容以查看导入器生成的结果。

主要是通过 AssetDatabaseExperimental.LookupArtifact 根据资源的 GUID,找到缓存的 Hash 值和对应路径

[MenuItem("资源检查/查询对象 Library 缓存路径")]
public static void GetSelectionLibraryPath()
{
    UnityEngine.Object obj = Selection.activeObject;
    if (obj == null) return;
    StringBuilder assetPathInfo = new StringBuilder();

    string assetPath = AssetDatabase.GetAssetPath(obj);
    GUID guid = AssetDatabase.GUIDFromAssetPath(assetPath);
    ArtifactID hash = AssetDatabaseExperimental.LookupArtifact(new ArtifactKey(guid));

    AssetDatabaseExperimental.GetArtifactPaths(hash, out var paths);

    assetPathInfo.Append(assetPath + "\n");
    assetPathInfo.Append("GUID: " + guid + "\n");

    foreach (var curVirtualPath in paths)
    {
        //.info files are the asset previews which you can see as part
        //of the asset icon
        if (curVirtualPath.EndsWith(".info"))
            continue;

        //The virtual path redirects somewhere, so we get the 
        //actual path on disk (or on the in memory database, accordingly)
        var curPath = Path.GetFullPath(curVirtualPath);
        assetPathInfo.Append(curPath + "\n");
    }
    Debug.Log("Path info for select asset:\n" + assetPathInfo.ToString());
}