Unity获取文件资源路径的两种方式

参考链接:
Unity官方论坛
Unity官方手册

[MenuItem("Tools/GetSelectPaths")]
    public static void Execute()
    {
        string[] strs = Selection.assetGUIDs;
        var curPath = System.IO.Directory.GetCurrentDirectory();
        foreach (var item in strs)
        {
            string path = AssetDatabase.GUIDToAssetPath(item);
            Debug.Log(curPath+"/"+path);
        }
    }
    [MenuItem("Example/Toggle Active of Selected %i")]
    static void DoToggle()
    {
        Object[] activeGOs = Selection.GetFiltered(
        		typeof(GameObject),
                SelectionMode.Editable | SelectionMode.TopLevel);

        foreach (GameObject obj in activeGOs)
        {
            obj.SetActive(!obj.activeSelf);
        }
    }
发布了31 篇原创文章 · 获赞 14 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/s15100007883/article/details/86512496