短视频源码php,自动查找重复贴图

短视频源码php素材库中,存在各种各样的贴图,为了自动查找重复贴图,所以使用了如下的代码:

using System.Collections;
using UnityEngine;
using UnityEditor;
using System.Security.Cryptography;
using System;
using System.IO;
using System.Collections.Generic;

public class FindRepetRes  {

	[MenuItem("Tools/Report/查找重复贴图")]
	static void ReportTexture()
	{
		Dictionary<string,string> md5dic = new Dictionary<string, string> ();
		string[] paths = AssetDatabase.FindAssets("t:prefab",new string[]{"Assets/Resources"});

		foreach (var prefabGuid in paths) {
			string prefabAssetPath = AssetDatabase.GUIDToAssetPath(prefabGuid);
			string[] depend = AssetDatabase.GetDependencies (prefabAssetPath,true);
			for (int i = 0; i < depend.Length; i++) {
				string assetPath = depend [i];
				AssetImporter importer = AssetImporter.GetAtPath(assetPath);
				//满足贴图和模型资源
				if (importer is TextureImporter || importer is ModelImporter) {
					string md5 = GetMD5Hash(Path.Combine(Directory.GetCurrentDirectory(),assetPath));
					string path;
				
					if (!md5dic.TryGetValue (md5, out path)) {
						md5dic [md5] = assetPath;
					}else {
						if (path != assetPath) {
							Debug.LogFormat ("{0} {1} 资源发生重复!", path, assetPath);
						}
					}
				}
			}
		}
	}
	
	/// <summary>
	/// 获取文件Md5
	/// </summary>
	/// <returns>The M d5 hash.</returns>
	/// <param name="filePath">File path.</param>
	static string GetMD5Hash(string filePath)
	{
		MD5 md5 = new MD5CryptoServiceProvider();
		return BitConverter.ToString(md5.ComputeHash(File.ReadAllBytes(filePath))).Replace("-", "").ToLower();
	}
}

以上就是短视频源码php中自动查找重复贴图用到的代码,更多信息欢迎关注之后的文章
本文转载自网络,转载仅为分享干货知识,如有侵权欢迎联系云豹科技进行删除处理

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值