首页 > 编程语言 > 详细

unity已知一个资源的路径,查找其依赖项

时间:2019-08-17 12:30:50      阅读:121      评论:0      收藏:0      [点我收藏+]
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;

public class Test
{
    [MenuItem("BuildTool/Lugs")]
    static void LugsTest()
    {
        string assetpath = "Assets/UI/Prefab/ui_login/ui_login.prefab";
        string[] a = GetAssetDependencies(assetpath);
        for (int i = 0, iMax = a.Length; i < iMax; ++i)
        {
            Debug.Log(a[i]);
        }
    }

    static string[] GetAssetDependencies(string assetPath)
    {
        if (!File.Exists(assetPath))
            return null;
        string[] dependecies = AssetDatabase.GetDependencies(assetPath);
        return dependecies;
    }
}

执行结果:

技术分享图片

unity已知一个资源的路径,查找其依赖项

原文:https://www.cnblogs.com/luguoshuai/p/11367817.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!