static void _MakeAtlas() { //Debug.Log(string.Format("UI Texture To Prefab")); string spriteDir = Application.dataPath + "/Resources/UI/Sprites/"; var filesPath = GKFileUtil.GetFilesInDirectory(Application.dataPath + "/Art/_UI/Sprite2Prefab/"); foreach (var str in filesPath) { if (string.Empty != GKString.GetFromSuffix(str, ".png", true) || string.Empty != GKString.GetFromSuffix(str, ".jpg", true)) { string allPath = str; string assetPath = allPath.Substring(allPath.IndexOf("Assets")); Sprite sprite = AssetDatabase.LoadAssetAtPath <Sprite>(assetPath); GameObject go = new GameObject(sprite.name); go.AddComponent <SpriteRenderer>().sprite = sprite; var dir = GKFileUtil.GetDirctoryName(allPath); allPath = string.Format("{0}{1}/{2}.prefab", spriteDir, dir, sprite.name); GKFileUtil.CreateDirectoryFromFileName(allPath); string prefabPath = allPath.Substring(allPath.IndexOf("Assets")); PrefabUtility.CreatePrefab(prefabPath, go); GameObject.DestroyImmediate(go); } } }
/* * Depending on your writing habits, * You need to develop various parsing methods that only implement simple parsing functions. * */ static public void ScoureCodeObfusation(string[] paths) { // One by one get directory. for (int i = 0; i < paths.Length; i++) { Debug.Log(string.Format("ScoureCodeObfusation file path: {0}", paths[i])); if (string.IsNullOrEmpty(paths[i])) { continue; } List <string> list = new List <string>(); string appendLine = "\tprivate void ObfuscationMethod_" + UnityEngine.Random.Range(0, 1000).ToString() + "(){} // For code obfuscation."; // Get files. var fs = GKFileUtil.GetFilesInDirectory(paths[i]); foreach (var f in fs) { if (!GKFileUtil.FilterInvalidFiles(f)) { continue; } bool bAppend = false; bool bFinished = false; list.Clear(); string strLine = ""; StreamReader sr = new StreamReader(f); while (null != (strLine = sr.ReadLine())) { list.Add(strLine); if (!bFinished) { // The new line contains '{', and meets the additional conditions. if (bAppend && strLine.Contains("{")) { list.Add(appendLine); bAppend = false; bFinished = true; } else { // At the beginning of the line is not to judge or / / / *, *. if (string.IsNullOrEmpty(strLine) || strLine.Trim().StartsWith("//") || strLine.Trim().StartsWith("/*") || strLine.Trim().StartsWith("*")) { continue; } // Check the read result and if it don't contains '{' lineNum++. if (strLine.Contains("public class")) { if (strLine.Contains("{")) { list.Add(appendLine); bAppend = false; bFinished = true; } else { bAppend = true; } } //... } } } sr.Close(); StreamWriter sw = new StreamWriter(f, false); foreach (var l in list) { sw.WriteLine(l); } sw.Close(); } } }