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

网站cdn加速怎么入侵公司网站维护该谁来做

网站cdn加速怎么入侵,公司网站维护该谁来做,网站建设网络推广公司,网架公司排行具体流程#xff1a; 找到工程中使用到的所有字体找到工程和场景中包含Text的所有对象展示要替换的字体名字让用户选择通过用户选择的字体#xff0c;展示响应的物体对象一键替换 通过AssetDatabase.FindAssets找到工程中包含的所有字体#xff1a; private Liststrin…具体流程 找到工程中使用到的所有字体找到工程和场景中包含Text的所有对象展示要替换的字体名字让用户选择通过用户选择的字体展示响应的物体对象一键替换 通过AssetDatabase.FindAssets找到工程中包含的所有字体 private Liststring FindAllFonts(){Liststring list new Liststring();// 获取所有字体文件string[] fontGUIDs AssetDatabase.FindAssets(t:Font);foreach (string fontGUID in fontGUIDs){string fontPath AssetDatabase.GUIDToAssetPath(fontGUID);Font font AssetDatabase.LoadAssetAtPathFont(fontPath);list.Add(font.name);}list.Add(Arial);//默认字体添加进去return list;} 通过AssetDatabase.FindAssets找到工程中的所有预制体 private ListGameObject GetAllPrefabByAssetDatabase(params string[] path){ListGameObject _prefabList new ListGameObject();string[] _guids AssetDatabase.FindAssets(t:Prefab, path);string _prefabPath ;GameObject _prefab;foreach (var _guid in _guids){_prefabPath AssetDatabase.GUIDToAssetPath(_guid);_prefab AssetDatabase.LoadAssetAtPath(_prefabPath, typeof(GameObject)) as GameObject;_prefabList.Add(_prefab);} #if UNITY_2020_1_OR_NEWERText[] texts GameObject.FindObjectsOfTypeText(true);foreach (var text in texts){_prefabList.Add(text.gameObject);} #elseScene activeScene EditorSceneManager.GetActiveScene();GameObject[] allObjectsInScene activeScene.GetRootGameObjects();foreach (var obj in allObjectsInScene){Text[] texts obj.GetComponentsInChildrenText(true);foreach (var text in texts){_prefabList.Add(text.gameObject);}} #endifreturn _prefabList;} 过滤没有含Text组件的对象 private ListGameObject FilterNoTextPrefabs(){ListGameObject templist new ListGameObject();Dic_Font_Prefabs.Clear();foreach (var prefab in prefabs){Text[] texts prefab.GetComponentsInChildrenText(true);if (texts.Length ! 0){foreach (var text in texts){if (text.font ! null){if (!Dic_Font_Prefabs.ContainsKey(text.font.name)){Dic_Font_Prefabs.Add(text.font.name, new ListGameObject());//根据Font类型添加一个Text集合到字典中}if (!Dic_Font_Prefabs[text.font.name].Contains(prefab)){Dic_Font_Prefabs[text.font.name].Add(prefab);}if (!templist.Contains(prefab)){templist.Add(prefab);//包含该Text的预制体添加到集合中}}}}}return templist;} 最后用户选择完要替换的字体选择开始替换即可。 TextMeshPro跟Text是一个道理只需要把代码中响应的Text和Font改为TextMeshProGUI和FontAssets即可。 最后附上完整代码 using System.Collections.Generic; using UnityEngine; using UnityEditor; using UnityEditorInternal; using UnityEngine.UI; using System.Linq; using UnityEditor.SceneManagement; using UnityEngine.SceneManagement; /// summary /// 查找替换工程场景中Text的Font /// /summary public class ChangePrefabFont : EditorWindow {[MenuItem(Tools/替换字体/Text)]//入口static void GetWindow()//静态函数{//创建窗口ChangePrefabFont window EditorWindow.GetWindowChangePrefabFont(Text字体替换窗口);//生成一个unity窗口弹窗window.Show();//展示OnGUI中的界面显示}#region 属性/// summary/// 工程中包含的字体的名字/// /summaryListstring fontsOnAssets new Liststring();/// summary/// 对应字体是否需要替换/// /summaryListbool textPaidFontRelpace new Listbool();/// summary/// 代替要替换的字体的字体/// /summaryListFont textReplaceFonts new ListFont();/// summary/// 预制体集合/// /summaryListGameObject prefabs new ListGameObject();/// summary/// 根据字体类型分类的预制体对象/// /summaryDictionarystring, ListGameObject Dic_Font_Prefabs new Dictionarystring, ListGameObject();#endregionprivate void OnEnable(){InitFont();}private void OnGUI(){InitPrefabs();#region 显示替换选项EditorGUILayout.LabelField(下面是工程中包含的字体和工程中场景中的对象使用的字体情况。请选择要替换的字体);for (int i 0; i fontsOnAssets.Count; i){EditorGUILayout.BeginHorizontal();EditorGUILayout.LabelField($更换[{fontsOnAssets[i]}]字体);textPaidFontRelpace[i] EditorGUILayout.Toggle(textPaidFontRelpace[i], GUILayout.Width(position.width));//是否要替换当前字体的复选框EditorGUILayout.EndHorizontal();EditorGUILayout.BeginHorizontal();EditorGUILayout.LabelField($ 预制体数量{GetGetUseFontPrefabCount(fontsOnAssets[i])});if (!textPaidFontRelpace[i]){if (Dic_Font_Prefabs.ContainsKey(fontsOnAssets[i])){foreach (var item in Dic_Font_Prefabs[fontsOnAssets[i]]){if (prefabs.Contains(item)){prefabs.Remove(item);}}}}else{EditorGUILayout.LabelField($代替【{fontsOnAssets[i]}】的字体);textReplaceFonts[i] (Font)EditorGUILayout.ObjectField(textReplaceFonts[i], typeof(Font), true);//代替的字体复选框if (Dic_Font_Prefabs.ContainsKey(fontsOnAssets[i])){foreach (var item in Dic_Font_Prefabs[fontsOnAssets[i]]){if (!prefabs.Contains(item)){prefabs.Add(item);}}}}EditorGUILayout.EndHorizontal();}EditorGUILayout.Space();#endregion#region 开始替换操作if (GUILayout.Button(开始替换)){if (textReplaceFonts null || textReplaceFonts.Count 0){EditorUtility.DisplayDialog(提示, 没有字体, 确定);return;}if (prefabs null || prefabs.Count 0){EditorUtility.DisplayDialog(提示, 没有需要替换的对象, 确定);return;}ListGameObject ReplaceGo new ListGameObject();Dictionarystring, Font Dic_Font_ReplaceFont new Dictionarystring, Font();for (int i 0; i textPaidFontRelpace.Count; i){if (textPaidFontRelpace[i] true){if (textReplaceFonts[i] ! null){if (Dic_Font_Prefabs.ContainsKey(fontsOnAssets[i])){ReplaceGo.AddRange(Dic_Font_Prefabs[fontsOnAssets[i]]);Dic_Font_ReplaceFont.Add(fontsOnAssets[i], textReplaceFonts[i]);}else{EditorUtility.DisplayDialog(提示, $使用了【{fontsOnAssets[i]}】字体的预制体数量为0, 确定);}}else{EditorUtility.DisplayDialog(提示, $【{fontsOnAssets[i]}】的替代字体为空, 确定);}}}if (ReplaceGo.Count 0){EditorUtility.DisplayDialog(提示, 没有需要替换的对象, 确定);}else{string hintInfo ;foreach (var font in Dic_Font_ReplaceFont){hintInfo ${font.Key} {font.Value.name}\n;}if (EditorUtility.DisplayDialog(确认进行下面的替换, hintInfo, 确定, 取消)){foreach (var font in Dic_Font_ReplaceFont){ReplaceFont(Dic_Font_Prefabs[font.Key], font.Key, font.Value);}SaveChangedToAsset(prefabs);}}}#endregion#region 预制体列表InitReorderableList();if (reorderableList ! null reorderableList.count ! 0){scrollPos EditorGUILayout.BeginScrollView(scrollPos);reorderableList.DoLayoutList();EditorGUILayout.EndScrollView();}else{EditorGUILayout.LabelField(提示没有需要替换字体的预制体);}#endregion}#region 列表和滚动窗口ReorderableList reorderableList;//列表显示Vector2 scrollPos;//滚动窗口需要private void DrawHeader(Rect rect){EditorGUI.LabelField(rect, 对象列表数量 prefabs.Count);}private void DrawElement(Rect rect, int index, bool isActive, bool isFocused){rect.height - 4;rect.y 2;prefabs[index] (GameObject)EditorGUI.ObjectField(rect, 包含Text的对象, prefabs[index], typeof(GameObject), true);}private void AddItem(ReorderableList list){prefabs.Add(null);}#endregion#region 逻辑方法/// summary/// 字体相关初始化/// /summaryprivate void InitFont(){textPaidFontRelpace.Clear();textReplaceFonts.Clear();fontsOnAssets FindAllFonts();foreach (var item in fontsOnAssets){textPaidFontRelpace.Add(false);textReplaceFonts.Add(null);}}/// summary/// 预制体相关初始化/// /summaryprivate void InitPrefabs(){prefabs GetAllPrefabByAssetDatabase();prefabs FilterNoTextPrefabs();prefabs.Clear();foreach (var item in Dic_Font_Prefabs){prefabs.AddRange(item.Value);}}/// summary/// 初始化链表操作对象/// /summaryprivate void InitReorderableList(){prefabs prefabs.Distinct().ToList();reorderableList new ReorderableList(prefabs, typeof(GameObject), true, true, true, true);reorderableList.drawHeaderCallback DrawHeader;reorderableList.drawElementCallback DrawElement;reorderableList.onAddCallback AddItem;}#endregion#region 功能方法#region 查找和过滤/// summary/// 找到工程和场景中的含有Text组件的对象/// /summary/// param namepath/param/// returns/returnsprivate ListGameObject GetAllPrefabByAssetDatabase(params string[] path){ListGameObject _prefabList new ListGameObject();string[] _guids AssetDatabase.FindAssets(t:Prefab, path);string _prefabPath ;GameObject _prefab;foreach (var _guid in _guids){_prefabPath AssetDatabase.GUIDToAssetPath(_guid);_prefab AssetDatabase.LoadAssetAtPath(_prefabPath, typeof(GameObject)) as GameObject;_prefabList.Add(_prefab);} #if UNITY_2020_1_OR_NEWERText[] texts GameObject.FindObjectsOfTypeText(true);foreach (var text in texts){_prefabList.Add(text.gameObject);} #elseScene activeScene EditorSceneManager.GetActiveScene();GameObject[] allObjectsInScene activeScene.GetRootGameObjects();foreach (var obj in allObjectsInScene){Text[] texts obj.GetComponentsInChildrenText(true);foreach (var text in texts){_prefabList.Add(text.gameObject);}} #endifreturn _prefabList;}/// summary/// 过滤没有包含Text的预制体/// 过滤没有包含付费字体的预制体/// 根据Text类型分类/// /summary/// param namegameObjects/param/// returns/returnsprivate ListGameObject FilterNoTextPrefabs(){ListGameObject templist new ListGameObject();Dic_Font_Prefabs.Clear();foreach (var prefab in prefabs){Text[] texts prefab.GetComponentsInChildrenText(true);if (texts.Length ! 0){foreach (var text in texts){if (text.font ! null){if (!Dic_Font_Prefabs.ContainsKey(text.font.name)){Dic_Font_Prefabs.Add(text.font.name, new ListGameObject());//根据Font类型添加一个Text集合到字典中}if (!Dic_Font_Prefabs[text.font.name].Contains(prefab)){Dic_Font_Prefabs[text.font.name].Add(prefab);}if (!templist.Contains(prefab)){templist.Add(prefab);//包含该Text的预制体添加到集合中}}}}}return templist;}/// summary/// 找到工程中的所有字体文件/// /summary/// returns返回字体名称列表/returnsprivate Liststring FindAllFonts(){Liststring list new Liststring();// 获取所有字体文件string[] fontGUIDs AssetDatabase.FindAssets(t:Font);foreach (string fontGUID in fontGUIDs){string fontPath AssetDatabase.GUIDToAssetPath(fontGUID);Font font AssetDatabase.LoadAssetAtPathFont(fontPath);list.Add(font.name);}list.Add(Arial);//默认字体添加进去return list;}#endregion#region 替换字体方法/// summary/// 替换Text的字体/// /summary/// param nametexts要替换的Text集合/param/// param namefontName要替换的字体的名字/param/// param namefont用来替换的字体/paramprivate void ReplaceFont(ListGameObject gameObjects, string fontName, Font font){foreach (var go in gameObjects){Text[] texts go.GetComponentsInChildrenText(true);foreach (var text in texts){if (text.font ! null){if (text.font.name fontName){text.font font;}}//else//{// text.font Resources.GetBuiltinResourceFont(Arial.ttf);//}}}}/// summary/// 保存更改/// /summary/// param namegameObjects/paramprivate void SaveChangedToAsset(ListGameObject gameObjects){foreach (var gameObject in gameObjects){EditorUtility.SetDirty(gameObject);}AssetDatabase.SaveAssets();AssetDatabase.Refresh();EditorUtility.DisplayDialog(提示, 替换完毕, 确定);}#endregionprivate ListGameObject GetUseFontPrefabs(string font){if (Dic_Font_Prefabs.ContainsKey(font))return Dic_Font_Prefabs[font];elsereturn null;}private int GetGetUseFontPrefabCount(string font){ListGameObject temp GetUseFontPrefabs(font);return temp null ? 0 : temp.Count;}#endregion }
http://www.zqtcl.cn/news/288173/

相关文章:

  • 建站公司塔山双喜做饲料推广哪个网站好
  • php网站后台入口拼多多海外跨境电商入驻流程
  • 0731网站平面logo设计公司
  • 网站设计制作报价图片欣赏wordpress福利
  • 网站上有什么作用自己做网站需要学什么
  • 在哪里做马可波罗网站wordpress中文站cn
  • 威海外贸建站制作游戏的平台
  • 网站栏目策划 有思想的新闻网站建设开发的流程
  • 网站描述修改潍坊百度网站排名
  • 网站开发设计的技术网站开发可能存在的困难
  • 单片机做网站网站地图那么建设
  • 手机版网站建设软件wordpress主题开发ide
  • 网站建设的技术有哪些内容网站推广优化排名
  • 网站开发用jsp网站开发需要什么技术
  • 网站打开404错误怎么解决网站开发树形图
  • 好的建设网站公司哪家好湖南省做网站的
  • 网站怎么上传网站建设可行性分析表
  • 东营做网站优化价格企业网站开发一般多少钱
  • 高端网站设计公司排名邢台哪里有做网站的
  • 广州网站开发 英诺科技营销式网站建设
  • 网站存在的缺陷编程的基础知识
  • flash同视频做网站天津建设工程信息网投标信息系统
  • 湛江做网站开发手机网址大全主页网址
  • 平面网站设计如何租用网站服务器
  • 课程视频网站建设的必要性专利减缓在哪个网站上做
  • 正规品牌网站设计品牌网站建设开发 脚本语言
  • 潍坊模板建站定制网站规划管理部门的网站建设
  • 光明楼网站建设九一人才网赣州招聘官网
  • 如何做网站监控wordpress修改文章点赞数
  • 佛山高端网站建设报价网站的建设属于无形资产