中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁(yè) > news >正文

網(wǎng)站設(shè)計(jì)介紹常用的搜索引擎

網(wǎng)站設(shè)計(jì)介紹,常用的搜索引擎,上海松江網(wǎng)站制作,華聯(lián)app每周四搶電影票我是編程一個(gè)菜鳥(niǎo),英語(yǔ)又不好,有的插件非常牛!我想學(xué)一學(xué),頁(yè)面全是英文,完全不知所措,我該怎么辦啊...嘗試在Unity中漢化一個(gè)插件 效果: 思路: 如何在Unity中把一個(gè)自己喜歡的插件…
我是編程一個(gè)菜鳥(niǎo),英語(yǔ)又不好,有的插件非常牛!我想學(xué)一學(xué),頁(yè)面全是英文,完全不知所措,我該怎么辦啊...

嘗試在Unity中漢化一個(gè)插件

效果:

請(qǐng)?zhí)砑訄D片描述

思路:

如何在Unity中把一個(gè)自己喜歡的插件變成中文?在Unity中編寫(xiě)插件一般會(huì)用到編輯器擴(kuò)展
在編輯器擴(kuò)展中想在Inspector顯示自己想要的屬性名或者別的什么,就需要用到編輯器擴(kuò)展的API
把這些固定的API存到一個(gè)字典里,例如“EditorGUILayout.PropertyField”,“LabelField”...我可以嘗試先讀取我們想要漢化插件的Editor文件夾下的每一個(gè)代碼的每一行
把每一行的每個(gè)字符與字典做一個(gè)對(duì)比
對(duì)比成功就說(shuō)明此行代碼可以被漢化,收集可以被漢化的代碼行,然后把可以被漢化的代碼行替換成我們想要的代碼
替換成功后保存代碼聽(tīng)起來(lái)好像沒(méi)啥問(wèn)題,試試看
  • 創(chuàng)建一個(gè)存儲(chǔ)字典的代碼
using System.Collections.Generic;
using UnityEngine;[CreateAssetMenu()]
public class SearchCharacterData : ScriptableObject
{[Header("檢索字符對(duì)")]public List<Item> items;[Header("添加字符對(duì)")]public bool addItem = false;private void OnValidate(){if (addItem){addItem = false;items.Add(new Item());}}/// <summary>/// 物品數(shù)據(jù)/// </summary>[System.Serializable]public class Item{public string startStr;public string endStr;}
}
  • 完成之后我們就可以在項(xiàng)目中創(chuàng)建一個(gè)自定義字典了
    在這里插入圖片描述

  • 在字典中添加幾對(duì)常用AIP用來(lái)測(cè)試
    在這里插入圖片描述

  • 創(chuàng)建一個(gè)編輯器窗口代碼

using System;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;[System.Serializable]
public class Editor_ChinesizationTool : EditorWindow
{private static Editor_ChinesizationTool _window;[MenuItem("Tools/漢化編輯器")]public static void GUIDRefReplaceWin(){Rect wr = new Rect(0, 0, 300, 1000);//窗口大小_window = (Editor_ChinesizationTool)GetWindow(typeof(Editor_ChinesizationTool), true, "漢化編輯");// false 表示不能??康?/span>_window.Show();}
}
沒(méi)想到要去翻譯一個(gè)插件,竟然要自己先寫(xiě)一個(gè)...造孽啊~
  • 讀文件
	 	/// <summary>/// 讀取數(shù)據(jù)/// </summary>/// <returns></returns>public List<string> ReadFileInfo(bool IsUpdateNewData = true){Datas.Clear();CurrentDatas.Clear();CurrentSplitDatas.Clear();if (IsUpdateNewData) NewSplitDatas.Clear();StreamReader sr = null;//讀取string assetsName = FileInfo.FullName;sr = File.OpenText(assetsName.Substring(assetsName.IndexOf("Assets")));//讀取文件//讀取所有行int line = 0;string data = null;do{data = sr.ReadLine();if (data != null){Datas.Add(data);CurrentDatas.Add(data);foreach (var item in searchCharacterData.items){string csData = FindString(data, item.startStr, item.endStr);if (csData != ""){CurrentSplitDatas.Add(new NewCSData(line, csData));if (IsUpdateNewData) NewSplitDatas.Add(new NewCSData(line, csData));break;}}}line++;} while (data != null);sr.Close();//關(guān)閉流sr.Dispose();//銷毀流return CurrentDatas;}
  • 將改好的數(shù)據(jù)進(jìn)行寫(xiě)入
		void WriteFileInfo(List<string> datas){StreamWriter sw;//寫(xiě)入if (!FileInfo.Exists){Debug.LogError("無(wú)法寫(xiě)入,沒(méi)有該文件");return;}ClearData(path);sw = FileInfo.AppendText();//打開(kāi)文件foreach (string linedata in datas){sw.WriteLine(linedata);}sw.Flush();//清除緩沖區(qū)sw.Close();//關(guān)閉流sw.Dispose();//銷毀流//ReadFileInfo();}
  • 稍稍修正一下編輯器頁(yè)面,隨便導(dǎo)入一個(gè)插件試試看
    在這里插入圖片描述

源碼

注意!此文件需要放在Editor文件夾下才可以正常使用
using System;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;[System.Serializable]
public class Editor_ChinesizationTool : EditorWindow
{private static Editor_ChinesizationTool _window;public string modelPath = "Assets";public List<CSData> cslist = new List<CSData>();public static Rect modelRect;int maxLineCount = 5;Vector2 csDataPos, contentPos;SearchCharacterData searchCharacterData = null;CSData CurrentCSData = null;[MenuItem("Tools/漢化編輯器")]public static void GUIDRefReplaceWin(){Rect wr = new Rect(0, 0, 300, 1000);//窗口大小_window = (Editor_ChinesizationTool)GetWindow(typeof(Editor_ChinesizationTool), true, "漢化編輯");// false 表示不能??康?/span>_window.Show();}private Material m_material;//1private void OnEnable(){m_material = new Material(Shader.Find("Hidden/Internal-Colored"));//2m_material.hideFlags = HideFlags.HideAndDontSave;//3}void OnGUI(){EditorGUILayout.Space();EditorGUILayout.LabelField("將文件夾拖拽到此處");EditorGUILayout.Space();GUI.SetNextControlName("input1");//設(shè)置下一個(gè)控件的名字modelRect = EditorGUILayout.GetControlRect();modelPath = EditorGUI.TextField(modelRect, modelPath);EditorGUILayout.Space();DragFolder();EditorGUILayout.Space();searchCharacterData = EditorGUILayout.ObjectField("", searchCharacterData, typeof(SearchCharacterData), true) as SearchCharacterData;// 導(dǎo)出材質(zhì)if (searchCharacterData == null){GUILayout.Label("請(qǐng)?zhí)砑幼值?#34;);return;}if (GUILayout.Button("讀取文件")){ReadFile();CurrentCSData = null;}if (CurrentCSData == null){int currentLineCount = 1;csDataPos = EditorGUILayout.BeginScrollView(csDataPos, GUILayout.Width(1000), GUILayout.Height(500));bool isLineEnd = true;maxLineCount = EditorGUILayout.IntField("每行顯示腳本的個(gè)數(shù)", maxLineCount);foreach (CSData csdate in cslist){if (currentLineCount == 1){GUILayout.BeginHorizontal();isLineEnd = false;}if (GUILayout.Button(csdate.name)){CurrentCSData = csdate;}if (currentLineCount == maxLineCount){GUILayout.EndHorizontal();currentLineCount = 0;isLineEnd = true;}currentLineCount++;}if (isLineEnd == false){GUILayout.EndHorizontal();}GUILayout.EndScrollView();}if (CurrentCSData != null){EditorGUILayout.BeginVertical("HelpBox");GUILayout.BeginHorizontal();csDataPos = EditorGUILayout.BeginScrollView(csDataPos, GUILayout.Width(500), GUILayout.Height(700));#region 顯示代碼int line = 1;lineLocations.Clear();foreach (var date in CurrentCSData.CurrentDatas){GUILayout.Label(line + "  " + date);foreach (var item in CurrentCSData.CurrentSplitDatas){if (line == item.line){LineLocation lineLocation = new LineLocation();Rect rect = GUILayoutUtility.GetLastRect();lineLocation.FirstRect = new Vector2(rect.x, rect.y - csDataPos.y);lineLocation.FirstRectOffset = csDataPos;lineLocations.Add(lineLocation);}}line++;}GUILayout.EndScrollView();GUILayout.Space(100);#endregioncontentPos = EditorGUILayout.BeginScrollView(contentPos, GUILayout.Width(700), GUILayout.Height(700));for (int i = 0; i < CurrentCSData.CurrentSplitDatas.Count; i++){//GUILayout.BeginHorizontal();GUILayout.Label(CurrentCSData.CurrentSplitDatas[i].line + 1 + "  " + CurrentCSData.CurrentDatas[CurrentCSData.CurrentSplitDatas[i].line]);//找到可更換數(shù)據(jù)lineLocations[i].FirstRect.y += contentPos.y;lineLocations[i].LastRectOffset = contentPos;Rect rect = GUILayoutUtility.GetLastRect();lineLocations[i].LastRect = new Vector2(rect.x, rect.y);CurrentCSData.NewSplitDatas[i].data = EditorGUILayout.TextField(CurrentCSData.NewSplitDatas[i].data);//GUILayout.EndHorizontal();}foreach (var item in lineLocations){m_material.SetPass(0);//4GL.Begin(GL.LINES);GL.Color(Color.red);GL.Vertex3(item.FirstRect.x - 100+10, LimitMax(item.FirstRect.y + 30,690+ item.LastRectOffset.y, item.LastRectOffset.y), 0);GL.Vertex3(item.FirstRect.x - 105+10, LimitMax(item.FirstRect.y + 30, 690+ item.LastRectOffset.y, item.LastRectOffset.y), 0);GL.End();GL.Begin(GL.LINES);GL.Color(Color.black);GL.Vertex3(item.FirstRect.x - 100+10, LimitMax(item.FirstRect.y + 30,690 + item.LastRectOffset.y, item.LastRectOffset.y), 0);//================================================================================================GL.Vertex3(item.LastRect.x-10, LimitMax(item.LastRect.y + 10, 690 + item.LastRectOffset.y, item.LastRectOffset.y), 0); GL.End();GL.Begin(GL.LINES);GL.Color(Color.red);GL.Vertex3(item.LastRect.x-10, LimitMax(item.LastRect.y + 10, 690 + item.LastRectOffset.y, item.LastRectOffset.y), 0);GL.Vertex3(item.LastRect.x-5, LimitMax(item.LastRect.y + 10, 690 + item.LastRectOffset.y, item.LastRectOffset.y), 0);GL.End();//Debug.Log("FirstRect:" + item.FirstRect+"__"+ "LastRect:"+ item.LastRect);//break;}GUILayout.EndScrollView();GUILayout.EndHorizontal();GUILayout.BeginHorizontal();if (GUILayout.Button("確認(rèn)更改")){CurrentCSData.ReadFileInfo(false);for (int i = 0; i < CurrentCSData.CurrentSplitDatas.Count; i++){CurrentCSData.CurrentDatas[CurrentCSData.CurrentSplitDatas[i].line] =ReplaceStr(CurrentCSData.CurrentDatas[CurrentCSData.CurrentSplitDatas[i].line],CurrentCSData.CurrentSplitDatas[i].data,CurrentCSData.NewSplitDatas[i].data);}for (int i = 0; i < CurrentCSData.Datas.Count; i++){CurrentCSData.Datas[i] = CurrentCSData.CurrentDatas[i];}CurrentCSData.WriterData();AssetDatabase.Refresh();}if (GUILayout.Button("重新選擇文件")){CurrentCSData = null;}GUILayout.EndHorizontal();GUILayout.EndVertical();}EditorGUILayout.Space();}List<LineLocation> lineLocations = new List<LineLocation>();public class LineLocation{public Vector2 FirstRectOffset;public Vector2 FirstRect;public Vector2 LastRectOffset;public Vector2 LastRect;}public void ReadFile(){GetAllFilesAndDertorys(modelPath, searchCharacterData);}/// <summary>/// 獲得拖拽文件/// </summary>void DragFolder(){//鼠標(biāo)位于當(dāng)前窗口if (mouseOverWindow == this){//拖入窗口未松開(kāi)鼠標(biāo)if (Event.current.type == EventType.DragUpdated){DragAndDrop.visualMode = DragAndDropVisualMode.Generic;//改變鼠標(biāo)外觀// 判斷區(qū)域if (modelRect.Contains(Event.current.mousePosition))GUI.FocusControl("input1");}//拖入窗口并松開(kāi)鼠標(biāo)else if (Event.current.type == EventType.DragExited){string dragPath = string.Join("", DragAndDrop.paths);// 判斷區(qū)域if (modelRect.Contains(Event.current.mousePosition))modelPath = dragPath;// 取消焦點(diǎn)(不然GUI不會(huì)刷新)GUI.FocusControl(null);}}}static string FindString(string str, string StartStr, string EndStr){if (str.Length < 3)return "";int index3 = str.IndexOf(StartStr);if (index3 != -1){int index4 = str.IndexOf(EndStr, index3);if (index4 != -1){return str.Substring(index3 + StartStr.Length, index4 - index3 - StartStr.Length);}}return "";}void GetAllFilesAndDertorys(string _path, SearchCharacterData searchCharacterData){//判斷路徑是否存在if (Directory.Exists(_path)){#region 找到Editor文件夾DirectoryInfo dir = new DirectoryInfo(_path);DirectoryInfo[] allDirs = dir.GetDirectories("*", SearchOption.AllDirectories);string EditorPath = "";foreach (var item in allDirs){//忽略.metaif (item.Name.EndsWith(".meta")) continue;string assetsName = item.FullName;assetsName = assetsName.Substring(assetsName.IndexOf("Assets"));if (item.Name == "Editor"){EditorPath = assetsName;break;}}#endregionif (EditorPath != ""){#region 得到Editor文件夾下所有的.cs文件DirectoryInfo editorDir = new DirectoryInfo(EditorPath);cslist.Clear();int ListIndex = 0;foreach (var item in editorDir.GetFiles("*", SearchOption.AllDirectories)){//忽略.metastring assetsName = item.FullName;assetsName = assetsName.Substring(assetsName.IndexOf("Assets"));if (item.Name.EndsWith(".meta")) continue;if (item.Name.EndsWith(".cs")){cslist.Add(new CSData(ListIndex, item, assetsName, searchCharacterData, this));}ListIndex++;}#endregionforeach (var item in cslist){item.ReadFileInfo();}}else{Debug.LogError("該目錄沒(méi)有Editor文件夾");}}}string ReplaceStr(string str, string oldStr, string newStr){if (str.Length < 3)return "";int strIndex = str.IndexOf(oldStr);if (strIndex != -1){string startStr = str.Substring(0, strIndex);string endStr = str.Substring(strIndex + oldStr.Length);return startStr + newStr + endStr;}return "";}public float LimitMax(float f, float maxValue = 690, float minValue = 0){//return f;return Math.Min(maxValue, Math.Max(f, minValue));}[System.Serializable]public class CSData{Editor_ChinesizationTool editor_ChinesizationTool = null;SearchCharacterData searchCharacterData = null;public string name;private FileInfo fileInfo;public int ListIndex = -1;public string path;/// <summary>/// 原始數(shù)據(jù)/// </summary>public List<string> Datas = new List<string>();/// <summary>/// 當(dāng)前數(shù)據(jù)/// </summary>public List<string> CurrentDatas = new List<string>();/// <summary>/// 新數(shù)據(jù)/// </summary>public List<NewCSData> CurrentSplitDatas = new List<NewCSData>();public List<NewCSData> NewSplitDatas = new List<NewCSData>();public FileInfo FileInfo{get{if (fileInfo == null){editor_ChinesizationTool.ReadFile();fileInfo = editor_ChinesizationTool.cslist[ListIndex].FileInfo;}return fileInfo;}set => fileInfo = value;}public CSData(int mListIndex, FileInfo mfileInfo, string path, SearchCharacterData searchCharacterData, Editor_ChinesizationTool parent){FileInfo = mfileInfo;this.path = path;this.name = FileInfo.Name;this.searchCharacterData = searchCharacterData;this.ListIndex = mListIndex;this.editor_ChinesizationTool = parent;}/// <summary>/// 寫(xiě)入數(shù)據(jù)/// </summary>public void WriterData(){WriteFileInfo(Datas);}/// <summary>/// 讀取數(shù)據(jù)/// </summary>/// <returns></returns>public List<string> ReadFileInfo(bool IsUpdateNewData = true){Datas.Clear();CurrentDatas.Clear();CurrentSplitDatas.Clear();if (IsUpdateNewData) NewSplitDatas.Clear();StreamReader sr = null;//讀取string assetsName = FileInfo.FullName;sr = File.OpenText(assetsName.Substring(assetsName.IndexOf("Assets")));//讀取文件//讀取所有行int line = 0;string data = null;do{data = sr.ReadLine();if (data != null){Datas.Add(data);CurrentDatas.Add(data);foreach (var item in searchCharacterData.items){string csData = FindString(data, item.startStr, item.endStr);if (csData != ""){CurrentSplitDatas.Add(new NewCSData(line, csData));if (IsUpdateNewData) NewSplitDatas.Add(new NewCSData(line, csData));break;}}}line++;} while (data != null);sr.Close();//關(guān)閉流sr.Dispose();//銷毀流return CurrentDatas;}void WriteFileInfo(List<string> datas){StreamWriter sw;//寫(xiě)入if (!FileInfo.Exists){Debug.LogError("無(wú)法寫(xiě)入,沒(méi)有該文件");return;}ClearData(path);sw = FileInfo.AppendText();//打開(kāi)文件foreach (string linedata in datas){sw.WriteLine(linedata);}sw.Flush();//清除緩沖區(qū)sw.Close();//關(guān)閉流sw.Dispose();//銷毀流//ReadFileInfo();}void ClearData(string path){StreamWriter tmpWrite = new StreamWriter(path);tmpWrite.Write("");tmpWrite.Close();}}[System.Serializable]public class NewCSData{public int line = 0;public string data = "";public NewCSData(int line, string data){this.line = line;this.data = data;}}
}

最后的最后:

我自己反正沒(méi)實(shí)踐過(guò),可以先拿這個(gè)玩玩看還是挺有意思的~
覺(jué)得有意思可以改巴改巴,也可以把建議放在評(píng)論區(qū),有空我就更新一下~
Demo源碼

http://www.risenshineclean.com/news/40372.html

相關(guān)文章:

  • 江蘇專業(yè)做網(wǎng)站淘寶關(guān)鍵詞排名
  • 做網(wǎng)站界面一般用什么來(lái)做廣告公司取名字參考大全
  • wordpress廣告窗插件搜索引擎優(yōu)化怎么做的
  • 企業(yè)商城網(wǎng)站 .net天津seo外包
  • 免費(fèi)英文網(wǎng)站建設(shè)學(xué)電商出來(lái)一般干什么工作
  • 深圳高端網(wǎng)站建設(shè)網(wǎng)頁(yè)設(shè)計(jì)鄭州企業(yè)網(wǎng)絡(luò)推廣外包
  • 建個(gè)網(wǎng)站多少錢app什么平臺(tái)可以打廣告做宣傳
  • 海南建設(shè)網(wǎng)站公司廣告文案
  • 網(wǎng)站設(shè)計(jì)錯(cuò)誤如何發(fā)布自己的廣告
  • 建設(shè)網(wǎng)站的五個(gè)步驟網(wǎng)站推廣的100種方法
  • jsp做新聞網(wǎng)站蘇州網(wǎng)站外包
  • 教務(wù)處網(wǎng)站建設(shè)西安seo推廣
  • 怎么做網(wǎng)站公司宣傳資料電商seo優(yōu)化是什么
  • ps企業(yè)站網(wǎng)站做多大的市場(chǎng)調(diào)研怎么寫(xiě)
  • 在線旅游攻略網(wǎng)站建設(shè)方案關(guān)鍵詞優(yōu)化好
  • 網(wǎng)站地圖怎么建設(shè)網(wǎng)頁(yè)制作教程步驟
  • 人人建站怎么做網(wǎng)站關(guān)鍵詞優(yōu)化
  • 做視頻網(wǎng)站視頻文件都存放在哪站長(zhǎng)之家seo綜合查詢
  • 網(wǎng)站建設(shè)丂金手指科杰湖南網(wǎng)絡(luò)推廣服務(wù)
  • 雅安網(wǎng)站制作福建seo顧問(wèn)
  • 投票網(wǎng)站怎么做網(wǎng)絡(luò)營(yíng)銷推廣的要點(diǎn)
  • wap多用戶網(wǎng)站站長(zhǎng)之家官網(wǎng)登錄入口
  • 網(wǎng)站集約化建設(shè)解讀百度推廣優(yōu)化是什么意思
  • 做音頻的網(wǎng)站正規(guī)接單賺傭金的平臺(tái)
  • 昆山住房和城鄉(xiāng)建設(shè)局網(wǎng)站優(yōu)化網(wǎng)站內(nèi)容
  • 做的網(wǎng)站電腦上跟手機(jī)上不一樣嗎seo優(yōu)化廠商
  • 農(nóng)產(chǎn)品網(wǎng)站建設(shè)計(jì)劃書(shū)seo技術(shù)介紹
  • 世界上網(wǎng)站做的好的例子品牌整合營(yíng)銷
  • 新疆生產(chǎn)建設(shè)兵團(tuán)社保局網(wǎng)站百度關(guān)鍵字推廣費(fèi)用
  • 珠海網(wǎng)站制作網(wǎng)絡(luò)推廣信息流優(yōu)化師前景