Exemplo n.º 1
0
        public PluginResponseInfo SaveConnection(Guid connectionID, Dictionary <string, string> connectionInfo)
        {
            ConfigDataHelper.SaveData <DummyArguments>(connectionID, connectionInfo);
            var resp = ResponseHelper.CreateOkResponse <PluginResponseInfo>();

            return(resp);
        }
Exemplo n.º 2
0
    public static void CopyAssets(bool clear = false)
    {
        if (clear)
        {
            DeleteAssets();
        }

        List <VersionData.VersionItem> list = new List <VersionData.VersionItem>();
        List <string> files = IGG.FileUtil.GetAllChildFiles(BuildSettings.assetBundleOutputPath, "ab");

        if (!ConstantData.enableCache && ConstantData.enableCustomCompress)
        {
            // 自定义压缩
            string inPath  = string.Format("{0}{1}", BuildSettings.assetBundleOutputPath, ConstantData.mainVersion);
            string outPath = "";
            if (ConstantData.enableMd5Name)
            {
                string md5 = IGG.FileUtil.CalcFileMd5(inPath);
                outPath = string.Format("{0}/{1}{2}", ConstantData.streamingAssetsPath, md5, ConstantData.assetBundleExt);
            }
            else
            {
                outPath = string.Format("{0}/data", ConstantData.streamingAssetsPath);
            }

            ThreadParam param = new ThreadParam();
            param.pathSrc = BuildSettings.assetBundleOutputPath;
            param.pathDst = ConstantData.streamingAssetsPath;
            param.list    = list;
            param.files   = files;
            param.index   = 0;
            param.lockd   = new object();

            PackFile(inPath, outPath, "data", param);

            int threadCount = SystemInfo.processorCount;

            List <Thread> threads = new List <Thread>();
            for (int i = 0; i < threadCount; ++i)
            {
                Thread thread = new Thread(new ParameterizedThreadStart(OnThreadCompress));
                thread.Start(param);

                threads.Add(thread);
            }

            while (true)
            {
                EditorUtility.DisplayProgressBar("压缩中...", string.Format("{0}/{1}", param.index, param.files.Count), Mathf.InverseLerp(0, param.files.Count, param.index));

                bool hasAlive = false;
                foreach (Thread thread in threads)
                {
                    if (thread.IsAlive)
                    {
                        hasAlive = true;
                        break;
                    }
                }

                if (!hasAlive)
                {
                    break;
                }

                Thread.Sleep(10);
            }
        }
        else
        {
            // 直接拷贝
            if (ConstantData.enableMd5Name)
            {
                string pathSrc = BuildSettings.assetBundleOutputPath;
                string pathDst = ConstantData.streamingAssetsPath;

                {
                    string file = string.Format("{0}/{1}", pathSrc, ConstantData.mainVersion);
                    CopyAsset(file, pathDst, list, "data");
                }

                int index = 0;
                foreach (string file in files)
                {
                    string name = file.Replace("\\", "/").Replace(pathSrc, "");
                    CopyAsset(file, pathDst, list, name);

                    ++index;
                    EditorUtility.DisplayProgressBar("拷贝中...", string.Format("{0}/{1}", index, files.Count), Mathf.InverseLerp(0, files.Count, index));
                }
            }
            else
            {
                // 把所有的ab文件拷贝进StreamAssets的ab目录下
                IGG.FileUtil.CopyDirectory(BuildSettings.assetBundleOutputPath, Application.streamingAssetsPath + "/ab/", ConstantData.assetBundleExt);

                // 拷贝manifest进StreamAssets,并命名为data
                string pathSrc = string.Format("{0}/{1}", BuildSettings.assetBundleOutputPath, ConstantData.mainVersion);
                string pathDst = string.Format("{0}/ab/data", Application.streamingAssetsPath);
                IGG.FileUtil.CopyFile(pathSrc, pathDst);
            }
        }

        if (ConstantData.enableMd5Name)
        {
            ConfigDataHelper.SaveData <VersionDataProxy>(VERSION_PATH, (data) =>
            {
                data.Items = list.ToArray();
            });
        }

        ClearObsolete(list);

        EditorUtility.ClearProgressBar();
        AssetDatabase.Refresh();
    }