首页 > 其他分享 >copy依赖资源到指定位置

copy依赖资源到指定位置

时间:2022-08-23 00:44:39浏览次数:38  
标签:dstFileFullPath 依赖 Log 指定 resPath Debug deps var copy

#

using System.IO;
using UnityEditor;
using UnityEngine;

namespace xui.Editor
{

    public class ResDeps
    {

        [MenuItem("Assets/myTool/打印依赖", false, 99)]
        public static void DumpDeps()
        {
            if (null == Selection.activeObject) return;
            var resPath = AssetDatabase.GetAssetPath(Selection.activeObject);
            if (string.IsNullOrEmpty(resPath)) return;

            var deps = AssetDatabase.GetDependencies(resPath, true);
            Debug.Log("========== begin");
            for (var i = 0; i < deps.Length; ++i)
            {
                Debug.Log(deps[i]);
            }
            Debug.Log("==========");
        }

        [MenuItem("Assets/myTool/打印并copy依赖", false, 99)]
        public static void DumpDeps2()
        {
            if (null == Selection.activeObject) return;
            var resPath = AssetDatabase.GetAssetPath(Selection.activeObject);
            if (string.IsNullOrEmpty(resPath)) return;

            var deps = AssetDatabase.GetDependencies(resPath, true);
            Debug.Log("========== begin");
            for (var i = 0; i < deps.Length; ++i)
            {
                Debug.Log(deps[i]);
                var dstFileFullPath = $"D:/MyConfiguration/win/Desktop/deps/{deps[i]}";
                if (!File.Exists(dstFileFullPath))
                {
                    var fileFolderFullPath = Path.GetDirectoryName(dstFileFullPath);
                    if (!Directory.Exists(fileFolderFullPath))
                        Directory.CreateDirectory(fileFolderFullPath);
                    File.Copy(deps[i], dstFileFullPath);
                    Debug.Log($"copy ->: {fileFolderFullPath}");
                }

                var srcFileMetaPath = $"{deps[i]}.meta";
                var dstFileMetaFullPath = $"{dstFileFullPath}.meta";
                if (!File.Exists(dstFileMetaFullPath))
                {
                    File.Copy(srcFileMetaPath, dstFileMetaFullPath);
                    Debug.Log($"copy meta");
                }
                Debug.Log($"=====");
            }
            Debug.Log("==========");
        }
    }

}

 

标签:dstFileFullPath,依赖,Log,指定,resPath,Debug,deps,var,copy
From: https://www.cnblogs.com/sailJs/p/16587293.html

相关文章

  • 解决rpm安装包依赖问题
    你需要安装几个rpm包,当时当你执行rpm-ivh*.rpm的时候,却提示需要一大堆依赖。你被不允许配置yum源,你也不能一个一个去尝试包和包之间的依赖关系。先在通互联网的机器......
  • Spring 循环依赖引起 This is very likely to create a memory leak 问题
    背景:在公司测试环境发布测试的时候,发布失败了。日志报错:Thisisverylikelytocreateamemoryleak 。但是奇怪的是我的本地idea是启动正常的。没问题的。然后就跟运维......
  • linux中查找nginx指定时间范围内的日志信息
    需求:在nginx中过滤出凌晨3:18-6:36的日志信息1、使用sed方式过滤注意:此方式开始和结束时间必须要在日志中真实存在,否则会匹配不到内容或匹配到末尾sed-n'/2022:03:18......
  • maven概述和maven依赖管理的概念
    maven概述什么是MavenApacheMaven是一个软件工程管理和整合工具。Maven是一个采用纯Java编写(跨平台)的开源项目管理工具,Maven采用了一种被称之为对象模型(POM:Pro......
  • maven概述以及maven依赖管理的概念和一键构建理念
    Maven概述Maven是一个项目管理工具,它包含了一个项目对象模型(POM:ProjectObjectModel),一组标准集合,一个项目生命周期(ProjectLifeCycle),一个依赖管理系统(Dependencyma......
  • yum离线安装rpm和依赖包
    离线安装说明      通常生产环境由于安全原因都无法访问互联网.此时就需要进行离线安装,主要有两种方式:源码编译、rpm包安装。源码编译耗费时间长且缺乏编译环......
  • Spring 05: 用DI(依赖注入)优化Spring接管下的三层项目架构
    背景用注解改造前面Spring博客集里(指Spring02)Spring接管下的三层项目架构对前面Spring博客集里(指Spring04)@Controller+@Service+@Repository3个注解的用法......
  • Spring 04: IOC控制反转 + DI依赖注入
    Spring中的IOC一种思想,两种实现方式IOC(InversionofControl):控制反转,是一种概念和思想,指由Spring容器完成对象创建和依赖注入核心业务:(a)对象的创建(b)依赖的......
  • python通过下标替换字符串,指定位置添加字符串
    指定下标替换字符串defreplace_char(old_string,char,index):'''字符串按索引位置替换字符'''old_string=str(old_string)#新的字符串=......
  • spring为什么不能只用一二级缓存来解决循环依赖?
    Springbean注入流程类实例化->属性注入->执行初始化方法->(如果有需要)生成代理对象->使用二级缓存存在的问题举例说明:A、B两个类相互依赖,初始化A的时候,第一步......