当前位置: 首页 > news >正文

做网站对电脑要求高吗上海做推广的引流公司

做网站对电脑要求高吗,上海做推广的引流公司,文章采集网站,建设网站书籍pdf图片资源冗余: UPR unity的性能优化工具检查资源 1.检查纹理读/写标记 开启纹理资源的读/写标志会导致双倍的内存占用 检查Inspector -> Advanced -> Read/Write Enabled选项 2.检查纹理资源alpha通道 如果纹理的alpha通道全部为0,或者全部为2…
图片资源冗余:

UPR unity的性能优化工具检查资源
在这里插入图片描述

1.检查纹理读/写标记
开启纹理资源的读/写标志会导致双倍的内存占用
检查Inspector -> Advanced -> Read/Write Enabled选项

2.检查纹理资源alpha通道
如果纹理的alpha通道全部为0,或者全部为255,可以认为其中不包含有效信息,此时应禁用’Alpha源’标志,否则会浪费这部分的内存。
检查Inspector -> Alpha Source选项

3.检查纯色纹理
纯色纹理的使用可能可以由一些设置来代替。由于某些情况下纯色纹理是必不可少的,此警告仅会在所使用的纹理较大(大于设定值, 默认为16x16)时才会触发。
Custom Parameters: heightThreshold : 16widthThreshold : 16

4.检查重复纹理

问题1 方案:可继承AssetPostprocessor对资源改动的时候检查是否有开启读/写标记

问题2,3 ,4 方案:定期检查
其中问题2,3只需要判断颜色通道比较简单不做解释
问题4 解决:
1.遍历所有贴图 用字典缓存 找到重复的资源
2.找到项目下所有材质,并且缓存
3.找到引用该重复贴图的材质
4.判断该材质所有引用贴图字段 如有和重复贴图相同 则替换
5.删除重复贴图

代码:

static void RemoveReportTexture(string[] searchInFolders){Dictionary<string, string> md5dic = new Dictionary<string, string>();HashSet<int> deleteTexInsId = new HashSet<int>();//string[] guids = AssetDatabase.FindAssets("t:Texture", new string[] { "Assets/actor", "Assets/FX", "Assets/scene", });string[] guids = AssetDatabase.FindAssets("t:Texture", searchInFolders);string[] matFiles = null;string[] matFilesContent = null;//Debug.Log("贴图" + guids.Length);//1.遍历所有贴图 用字典缓存 找到重复的资源 int progress = 0;foreach (var assetGuid in guids){string assetPath = AssetDatabase.GUIDToAssetPath(assetGuid); // 从GUID拿到资源的路径bool isCancel = EditorUtility.DisplayCancelableProgressBar("移除重复的贴图", assetPath, (float)progress / (float)guids.Length);progress++;string md5 = GetMD5Hash(Path.Combine(Directory.GetCurrentDirectory(), assetPath)); //获取md5string path;md5dic.TryGetValue(md5, out path);if (path == null){md5dic[md5] = assetPath;// Debug.Log(assetPath);}else{Debug.LogFormat("资源重复{0},{1}", path, assetPath);if (matFiles == null){//2.找到所有材质,并且缓存List<string> withoutExtensions = new List<string>() { ".mat" };matFiles = Directory.GetFiles(Application.dataPath, "*.*", SearchOption.AllDirectories).Where(s => withoutExtensions.Contains(Path.GetExtension(s).ToLower())).ToArray();matFilesContent = new string[matFiles.Length];for (int i = 0; i < matFiles.Length; i++){matFilesContent[i] = File.ReadAllText(matFiles[i]);}}Texture2D tex = AssetDatabase.LoadAssetAtPath<Texture2D>(path); //保留的图Texture2D deleteTex = AssetDatabase.LoadAssetAtPath<Texture2D>(assetPath); //删除的图//3.找到引用该贴图的所有材质for (int startIndex = 0; startIndex < matFiles.Length; startIndex++){string file = GetRelativeAssetsPath(matFiles[startIndex]);if (Regex.IsMatch(matFilesContent[startIndex], assetGuid)){Material material = AssetDatabase.LoadAssetAtPath<Material>(file);bool isUseTex = false;var textureNames = material.GetTexturePropertyNames();//Debug.Log("遍历所有需要修改替换贴图的材质:" + file + ",贴图数:" + textureNames.Length);//4.判断该材质所有引用贴图字段 如有和重复贴图相同 则替换for (int j = 0; j < textureNames.Length; j++){if (material.HasTexture(textureNames[j])) // 该方法获取不到不属于该shader的贴图(切换材质后unity会保留之前shader的信息){Texture texture = material.GetTexture(textureNames[j]); // 获取材质上的贴图引用if (texture != null){//Debug.Log("获取到图片名字:" + texture.name);if (texture.name == deleteTex.name){isUseTex = true;material.SetTexture(textureNames[j], tex);Debug.Log("修改的材质:" + file + "的贴图" + assetPath + ",assetGuid:" + assetGuid + ",替换为:" + path + "修改材质propertyName:" + textureNames[j]);EditorUtility.SetDirty(material);}}}}}}//5.替换完所有材质,删除该重复贴图//if(isChangeSucceedCount != referencesMatPath.Count)//{//    Debug.LogError("+++修改失败+++isChangeSucceedCount:"+ isChangeSucceedCount+ "+++referencesMatPath.Count:" + referencesMatPath.Count);//}//else//{//    AssetDatabase.DeleteAsset(assetPath);//    Debug.LogError("+++修改成功+++");//}Debug.Log("+++DeleteAsset+++:" + assetPath);deleteTexInsId.Add(deleteTex.GetInstanceID());AssetDatabase.DeleteAsset(assetPath);}}AssetDatabase.SaveAssets();EditorUtility.ClearProgressBar();if (deleteTexInsId.Count > 0){int checkProgress = 0;for (int startIndex = 0; startIndex < matFiles.Length; startIndex++){string file = GetRelativeAssetsPath(matFiles[startIndex]);bool isCancel = EditorUtility.DisplayCancelableProgressBar("检查材质是否缺少贴图", file, (float)checkProgress / (float)matFiles.Length);checkProgress++;Material material = AssetDatabase.LoadAssetAtPath<Material>(file);SerializedObject serializedMaterial = new SerializedObject(material);SerializedProperty texturesProperty = serializedMaterial.FindProperty("m_SavedProperties.m_TexEnvs");foreach (SerializedProperty textureProperty in texturesProperty){string propertyName = textureProperty.displayName;SerializedProperty textureReference = textureProperty.FindPropertyRelative("second.m_Texture");// 检查贴图引用是否丢失if (material.shader.FindPropertyIndex(propertyName) > 0 && textureReference.objectReferenceValue == null && deleteTexInsId.Contains(textureReference.objectReferenceInstanceIDValue)){Debug.LogError($"移除重复的模型贴图导致 Missing texture in material: {material.name}, Property: {propertyName}");}}}EditorUtility.ClearProgressBar();}}
主界面图集过多

在这里插入图片描述

主界面UI也就几个界面,但通过unity的Memory Profiler去看内存的时候 却发现了30个左右的图集,原因是因为拼接资源的时候没注意导致一个界面依赖了好几个图集,简单解决就是把主界面和其他界面一起用到的图片放到公用图集里去,然后就调整对应的图集,代码,界面

http://www.hotlads.com/news/5226.html

相关文章:

  • 机械加工网站色彩搭配自己有域名怎么建网站
  • 做网站运营的要求排行榜123网
  • 开封市建设中专继续教育网站企业软文代写
  • wordpress 调查问卷爱站网站seo查询工具
  • js做各类图表网站查询网域名查询
  • 药品行业做网站创建网站的基本流程
  • 学校如何建网站西点培训学校
  • 建设厅网站账户名忘了怎么查seo的推广技巧
  • 最轻快的wordpress主題郑州seo使用教程
  • 合肥专业做淘宝网站网络做推广广告公司
  • 淮南网站建设好北京seo公司公司
  • 淘宝的网站怎么做的好深圳网络推广招聘
  • 免费化妆品网站模板下载百度指数官方版
  • 网站自助建站开发制作如何优化
  • 如何用dedecms做网站北仑seo排名优化技术
  • 门户网站做吗谷歌搜索引擎香港入口
  • 为什么最近好多网站打不开了手机网站怎么优化
  • wordpress主题蓝色好的seo公司营销网
  • 做二维码报名网站谷歌play商店
  • 程序员常用的编程软件win7优化工具
  • 临沂做网站电话西安网络优化大的公司
  • 零基础学网站建设郑州怎么优化网站排名靠前
  • 做网站499seo优化网站教程百度
  • 冯耀宗seo课程惠州百度seo
  • wordpress automattic 公司位置西安关键词优化服务
  • 如何个网站做二维码seo优化总结
  • 网站建设公司基本流程网站流量
  • 织梦做博客类网站网站建设平台有哪些
  • 汉中城乡建设网站网站推广和精准seo
  • 新手站长做什么网站yandex网站推广