示例#1
0
 public static void OnInitialize()
 {
     EditorUtility.ClearProgressBar();
     Utility.dataPath            = System.Environment.CurrentDirectory;
     Utility.downloadURL         = ColaEditHelper.GetManifest().downloadURL;
     Utility.assetBundleMode     = AppConst.SimulateMode;
     Utility.getPlatformDelegate = ColaEditHelper.GetPlatformName;
     Utility.loadDelegate        = AssetDatabase.LoadAssetAtPath;
 }
示例#2
0
        private void ResetManifest()
        {
            var manifest = ColaEditHelper.GetManifest();

            manifest.assets  = new AssetData[0];
            manifest.dirs    = new string[0];
            manifest.bundles = new string[0];
            EditorUtility.SetDirty(manifest);
            AssetDatabase.SaveAssets();
            BuildCahe();
        }
示例#3
0
 private void DrawAssetUI()
 {
     GUILayout.BeginHorizontal("HelpBox");
     EditorGUILayout.LabelField("== 快捷功能 ==");
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     if (GUILayout.Button("Build Lua To StreamingAsset", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
     {
         ColaEditHelper.BuildLuaToStreamingAsset();
     }
     GUILayout.EndHorizontal();
 }
 private void DrawMiscUI()
 {
     GUILayout.BeginHorizontal("HelpBox");
     EditorGUILayout.LabelField("== 快捷功能 ==");
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     if (GUILayout.Button("打开AssetPath目录", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
     {
         ColaEditHelper.OpenDirectory(CommonHelper.AssetPath);
     }
     if (GUILayout.Button("打开GameLog文件目录", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
     {
         ColaEditHelper.OpenDirectory(Path.Combine(CommonHelper.AssetPath, "logs"));
     }
     GUILayout.EndHorizontal();
 }
示例#5
0
        private static void MarkAssetsWithFile()
        {
            var assetsManifest = ColaEditHelper.GetManifest();
            var assets         = Selection.GetFiltered <Object>(SelectionMode.DeepAssets);

            for (var i = 0; i < assets.Length; i++)
            {
                var asset = assets[i];
                var path  = AssetDatabase.GetAssetPath(asset);
                if (Directory.Exists(path) || path.EndsWith(".cs", System.StringComparison.CurrentCulture))
                {
                    continue;
                }
                if (EditorUtility.DisplayCancelableProgressBar(MARK_ASSETS, path, i * 1f / assets.Length))
                {
                    break;
                }

                var dir  = Path.GetDirectoryName(path);
                var name = Path.GetFileNameWithoutExtension(path);
                if (dir == null)
                {
                    continue;
                }
                dir = dir.Replace("\\", "/") + "/";
                if (name == null)
                {
                    continue;
                }

                var assetBundleName = TrimedAssetBundleName(Path.Combine(dir, name));
                ColaEditHelper.SetAssetBundleNameAndVariant(path, assetBundleName.ToLower(), null);
            }
            EditorUtility.SetDirty(assetsManifest);
            AssetDatabase.SaveAssets();
            EditorUtility.ClearProgressBar();
        }
示例#6
0
        private void BuildCahe()
        {
            _lastModify = File.GetLastWriteTime(Utility.AssetsManifestAsset);
            var manifest = ColaEditHelper.GetManifest();
            var sb       = new StringBuilder(512);

            for (var i = 0; i < manifest.bundles.Length; i++)
            {
                sb.AppendLine(string.Format("bundle[{0}]={1}", i, manifest.bundles[i]));
            }

            sb.AppendLine();
            for (var i = 0; i < manifest.dirs.Length; i++)
            {
                sb.AppendLine(string.Format("dir[{0}]={1}", i, manifest.dirs[i]));
            }
            sb.AppendLine();

            for (int i = 0; i < manifest.assets.Length; i++)
            {
                var assetData = manifest.assets[i];
                var desc      = string.Format("asset[{0}] = bundle:{1}, dir:{2}, name:{3}", i, assetData.bundle, assetData.dir, assetData.name);
                sb.AppendLine(desc);
            }


            _manifestStr = sb.ToString();
            _lineIndex.Clear();
            _lineIndex.Add(-1);
            for (var i = 0; i < _manifestStr.Length; i++)
            {
                if (_manifestStr[i] == '\n')
                {
                    _lineIndex.Add(i);
                }
            }
        }
    private void DrawAssetUI()
    {
        GUILayout.BeginHorizontal("HelpBox");
        EditorGUILayout.LabelField("== 快捷功能 ==");
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Build Lua To StreamingAsset", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
        {
            ColaEditHelper.BuildLuaToStreamingAsset();
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Zip Lua", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
        {
            var result = ZipHelper.Zip("Assets/Lua", Path.Combine(Application.dataPath, "../output/luaout.zip"));
            Debug.Log("Zip Lua结果:" + result);
        }
        if (GUILayout.Button("UnZip Lua", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
        {
            var filePath = Path.Combine("Assets", "../output/luaout.zip");
            if (File.Exists(filePath))
            {
                var result = ZipHelper.UnZip(filePath, Path.Combine("Assets", "../output"));
                Debug.Log("UnZip Lua结果:" + result);
            }
            else
            {
                Debug.LogError("解压错误!要解压的文件不存在!路径:" + filePath);
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("筛选出MD5码变化的lua文件", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
        {
            var md5Dic         = new Dictionary <string, string>();
            var luaMd5FilePath = ColaEditHelper.TempCachePath + "/LuaMD5.txt";
            if (File.Exists(luaMd5FilePath))
            {
                using (var sm = new StreamReader(luaMd5FilePath, Encoding.UTF8))
                {
                    var fileLines = sm.ReadToEnd().Split('\n');
                    foreach (var item in fileLines)
                    {
                        if (string.IsNullOrEmpty(item))
                        {
                            continue;
                        }
                        var lineContent = item.Split('|');
                        if (lineContent.Length == 2)
                        {
                            md5Dic[lineContent[0]] = lineContent[1];
                        }
                        else
                        {
                            Debug.LogError("LuaMD5.txt格式错误!内容为: " + lineContent);
                        }
                    }
                }
            }

            var luaFiles = new List <string>(Directory.GetFiles(LuaLogicPath, "*.lua", SearchOption.AllDirectories));
            var fLength  = (float)luaFiles.Count;

            int diffCnt = 0;
            for (int i = 0; i < luaFiles.Count; i++)
            {
                var    fileName = luaFiles[i];
                string curMd5   = FileHelper.GetMD5Hash(fileName);
                if (md5Dic.ContainsKey(fileName) && curMd5 == md5Dic[fileName])
                {
                    continue;
                }
                diffCnt++;
                string destPath = Regex.Replace(fileName, "^Assets", "output");
                FileHelper.EnsureParentDirExist(destPath);
                File.Copy(fileName, destPath, true);
                md5Dic[fileName] = curMd5;
                EditorUtility.DisplayProgressBar("正在分析Lua差异化..", fileName, i / fLength);
            }

            var sb = new StringBuilder();
            foreach (var item in md5Dic)
            {
                sb.AppendFormat("{0}|{1}", item.Key, item.Value).AppendLine();
            }
            FileHelper.WriteString(luaMd5FilePath, sb.ToString());
            EditorUtility.ClearProgressBar();

            Debug.LogFormat("Lua差异化分析完毕!共有{0}个差异化文件!", diffCnt);
        }
        GUILayout.EndHorizontal();
    }
示例#8
0
 private static AppSetting GetSetting()
 {
     return(ColaEditHelper.GetScriptableObjectAsset <AppSetting>("Assets/Editor/Settings/AppSetting.asset"));
 }
示例#9
0
 private static void CopyAssetBundles()
 {
     ColaEditHelper.CopyAssetBundlesTo(Path.Combine(Application.streamingAssetsPath, Utility.AssetBundles));
     AssetDatabase.Refresh();
 }
示例#10
0
 private static void BuildStandalonePlayer()
 {
     ColaEditHelper.BuildStandalonePlayer();
 }
示例#11
0
 private static void BuildAssetBundles()
 {
     ColaEditHelper.BuildManifest();
     ColaEditHelper.BuildAssetBundles();
 }
示例#12
0
 private static void BuildManifest()
 {
     ColaEditHelper.BuildManifest();
 }
示例#13
0
 private static void ClearAllABName()
 {
     ColaEditHelper.ClearAllAssetBundleName();
 }