コード例 #1
0
        public static byte[] LoadBytesFromUrl(string path, bool encryt = true)
        {
            string urlForFile = string.Format("{0}/{1}/{2}/{3}", url, ResSetting.GetChannelRes(), Version.LoadResVersion(), path)
                                + "?time=" + System.DateTime.Now.Ticks + "&r=" + UnityEngine.Random.Range(int.MinValue, int.MaxValue);

#if UNITY_EDITOR
            Debug.LogError("LoadBytesFromUrl -> " + urlForFile);
#endif

            WWW www = new WWW(urlForFile);
            if (Download(www))
            {
                if (!encryt)
                {
                    return(www.bytes);
                }
                else
                {
                    var bytes = www.bytes;
                    Decrypt(ref bytes);
                    return(www.bytes);
                }
            }
            return(null);
        }
コード例 #2
0
        //[MenuItem("Tools/打包/标签/差异化打标签", false, 3)]
        public static void MarkDiffFromRecord()
        {
            EditorUtility.DisplayProgressBar("清除标签...", "...", 0);

            ClearMarkDir("Assets");
            MarkFromRecord(assetrecord_build);

            EditorUtility.DisplayProgressBar("删除多余资源", "...", 0.33f);

            //删除多余资源
            List <RecordInfo> deletes = LoadRecordFile(record_del);

            DeleteNoNeedAssetBundle(deletes);


            EditorUtility.DisplayProgressBar("拷贝上次生成的资源", "...", 0.66f);

            //拷贝上次生成的资源
            if (!Directory.Exists("lastRes/"))
            {
                Debug.LogError("上次生成的资源不存在!");
                throw new System.Exception("上次生成的资源不存在--目录:lastRes/");
            }


            FileUtilTool.CopyFolder("lastRes/", ResSetting.AssetBundlesPath() + "/");

            EditorUtility.DisplayProgressBar("差异化打标签完成", "...", 1f);

            EditorUtility.ClearProgressBar();
        }
コード例 #3
0
        public void DownloadMD()
        {
            string urlMD = string.Format("{0}/{1}/{2}", ResSetting.GetChannelRes(), newVersion, mdFile);

            tip = "  下载MD文件 ";
            Debug.LogError(tip);
            StartCoroutine(DownloadFile(urlMD, OnDownloadMDFinish));
        }
コード例 #4
0
        public static void DeleteNoNeedAssetBundle(List <RecordInfo> deleted)
        {
            foreach (var k in deleted)
            {
                string bundleName = GetAssetBundleName(k.fileName);

                FileUtilTool.DelFile(ResSetting.AssetBundlesPath() + "/" + bundleName);
            }
        }
コード例 #5
0
ファイル: ResTool.cs プロジェクト: jewer3330/fantasy
        public static void UploadRes()
        {
            string sourcePath = ResSetting.build_res_path;
            string targetPath = string.Format("\\\\192.168.2.85\\FtpData\\{0}\\{1}", ResSetting.GetChannelRes(), Version.LoadVersionFromStreamingAsset());

            EditorUtility.DisplayProgressBar("上传资源", "...", 0);
            FileUtilTool.CopyFolder(sourcePath, targetPath);
            EditorUtility.DisplayProgressBar("上传资源", "...", 1);
            EditorUtility.ClearProgressBar();
        }
コード例 #6
0
ファイル: MDCheckTool.cs プロジェクト: jewer3330/fantasy
        void OnGUI()
        {
            EditorGUILayout.LabelField("比较版本号");

            version1 = EditorGUILayout.TextField(version1);
            version2 = EditorGUILayout.TextField(version2);

            if (GUILayout.Button("本地比较"))
            {
                string md1 = string.Format("{0}/{1}/{2}/{3}", "file://" + Application.dataPath.Replace("Assets", ""), ResSetting.build_root_path, version1, "MD.dat");
                string md2 = string.Format("{0}/{1}/{2}/{3}", "file://" + Application.dataPath.Replace("Assets", ""), ResSetting.build_root_path, version2, "MD.dat");

                DownloadFile(md1, OnMd1Finish);
                DownloadFile(md2, OnMd2Finish);
            }

            if (GUILayout.Button("远程比较"))
            {
                string md1 = string.Format("{0}/{1}/{2}/{3}", FileUtils.url, ResSetting.GetChannelRes(), version1, "MD.dat");
                string md2 = string.Format("{0}/{1}/{2}/{3}", FileUtils.url, ResSetting.GetChannelRes(), version2, "MD.dat");

                DownloadFile(md1, OnMd1Finish);
                DownloadFile(md2, OnMd2Finish);
            }

            int length = 0;

            scroll = EditorGUILayout.BeginScrollView(scroll);
            if (updates != null && updates.Count != 0)
            {
                EditorGUILayout.LabelField("需要更新的文件");
                length = OnGUIAssetbundleJsonData(updates);
                EditorGUILayout.LabelField("需要删除的文件");
                OnGUIAssetbundleJsonData(deletes);
            }
            GUI.color = Color.white;
            EditorGUILayout.EndScrollView();

            string text = "总大小 " + (length >> 20) + "MB";

            if (updates != null && updates.Count != 0)
            {
                text += " 总文件个数 " + j2.arrayRes.Length;
                text += " 更新文件个数 " + updates.Count;
                text += " 更新占比 " + (float)updates.Count / (float)(j2.arrayRes.Length);
                text += " 删除文件个数 " + deletes.Count;
                text += " 新增文件个数 " + adds.Count;
            }
            EditorGUILayout.LabelField(text);
        }
コード例 #7
0
        public void DownloadResVersionList()
        {
            string versionURL = string.Format("{0}/{1}", ResSetting.GetChannelRes(), "version.dat");

            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                string msg = string.Format("无法链接到网络");
                UIMessageBoxHelper.Show(
                    msg,
                    () =>
                {
                    ReStart();
                });
            }
            else
            {
                StartCoroutine(DownloadFile(versionURL, OnLoadVersionList));
            }
        }
コード例 #8
0
        public void DownLoadTips()
        {
            string urlUpdateTip = string.Format("{0}/{1}/{2}", ResSetting.GetChannelRes(), newVersion, "update.txt")
                                  + "?time=" + System.DateTime.Now.Ticks + "&r=" + UnityEngine.Random.Range(int.MinValue, int.MaxValue);

            tip = "从CDN下载更新Tips";
            Debug.LogError(tip);



            StartCoroutine(DownloadFile(urlUpdateTip, (www) =>
            {
                if (string.IsNullOrEmpty(www.error))
                {
                    updateTip = FileUtils.ReadStringFromBytes(www.bytes, false);
                }

                SuperBoBo.EventManager.Instance.FireEvent(UpdateEvent.Updater_DownloadUpdateTipDone);
            }));
        }
コード例 #9
0
        public static void DownloadFromUrl(string path)
        {
            string urlPath = string.Format("{0}/{1}/{2}/{3}", url, ResSetting.GetChannelRes(), Version.LoadResVersion(), path)
                             + "?time=" + System.DateTime.Now.Ticks + "&r=" + UnityEngine.Random.Range(int.MinValue, int.MaxValue);
            string persistentPath = string.Format("{0}/{1}", Application.persistentDataPath, path);

#if UNITY_EDITOR
            Debug.LogError("DownloadFromUrl -> " + urlPath);
#endif
            CreateFolderForFile(persistentPath);

            WWW www = new WWW(urlPath);
            if (Download(www))
            {
                //下载的什么写什么,不用加解密
                WriteFileInPersistent(path, www.bytes, false);
            }
            else
            {
                return;
            }
        }
コード例 #10
0
ファイル: IOSTool.cs プロジェクト: jewer3330/fantasy
        public static void BuildIOSProject(Version v)
        {
            //隐藏Resources目录
            BuildTool.ShowResourcesFolder(false);

            AssetDatabase.Refresh();
            AssetDatabase.SaveAssets();

            string[] levels = new string[] { BuildTool.startScene };
            try
            {
                string apkPath  = string.Format("{0}/{1}", ResSetting.AssetBundlesOutputPath, ResSetting.GetChannelRes());
                string location = string.Format("{0}/{1}", apkPath, v);
                UnityEditor.PlayerSettings.bundleVersion         = FileUtilTool.ReadFile("IOS_Build/appleversion.dat").Replace("\r\n", "\n").Replace("\n", "");
                UnityEditor.PlayerSettings.applicationIdentifier = "com.yxm.tankwar";
                UnityEditor.PlayerSettings.iOS.buildNumber       = BuildTool.versionCode.ToString();
                FileUtilTool.CreateFolderForFile(location);
                if (BuildTool.isDev)
                {
                    var result = BuildPipeline.BuildPlayer(levels, location, BuildTarget.iOS, BuildOptions.ConnectWithProfiler | BuildOptions.Development);
                }
                else
                {
                    var result = BuildPipeline.BuildPlayer(levels, location, BuildTarget.iOS, BuildOptions.None);
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError("build ios error: " + e.ToString());
            }
            finally
            {
                //恢复
                BuildTool.ShowResourcesFolder(true);
            }
        }
コード例 #11
0
ファイル: StandaloneTool.cs プロジェクト: jewer3330/fantasy
        public static void BuildStandaloneProject(Version v)
        {
            //隐藏Resources目录
            BuildTool.ShowResourcesFolder(false);

            AssetDatabase.Refresh();
            AssetDatabase.SaveAssets();

            string[] levels = new string[] { BuildTool.startScene };
            try
            {
                string apkPath  = string.Format("{0}/{1}", ResSetting.AssetBundlesOutputPath, ResSetting.GetChannelRes());
                string location = string.Format("{0}/{1}.exe", apkPath, v);
                UnityEditor.PlayerSettings.bundleVersion         = FileUtilTool.ReadFile("IOS_Build/appleversion.dat");
                UnityEditor.PlayerSettings.applicationIdentifier = "com.yxm.tankwar";
                FileUtilTool.CreateFolderForFile(location);
                var result = BuildPipeline.BuildPlayer(levels, location, BuildTarget.StandaloneWindows64, BuildOptions.None);
            }
            catch (System.Exception e)
            {
                Debug.LogError("build StandaloneWindows64 error: " + e.ToString());
            }
            finally
            {
                //恢复
                BuildTool.ShowResourcesFolder(true);
            }
        }
コード例 #12
0
ファイル: AndroidTool.cs プロジェクト: jewer3330/fantasy
        public static void BuildApkMiniNoGenRes()
        {
            Version v = Version.LoadVersionFromStreamingAsset();

            byte[] bytes = FileUtils.ReadBytesFromStreaming("Audio/GeneratedSoundBanks/Android/Init.bnk", false);

            FileUtilTool.DeleteFolder("Assets/StreamingAssets/");

            //写入Version文件和写入fullApkIdentify文件
            Version.SaveVersion2StreamingAsset(v);

            //写入配置信息
            //WriteApkConfig();

            //写入其他文件
            FileUtils.WriteFile(Application.streamingAssetsPath + "/Audio/GeneratedSoundBanks/Android/Init.bnk", bytes, false);
            string movePath = string.Format("{0}/{1}", ResSetting.build_root_path, v);

            FileUtilTool.CopyFolder(movePath + "/Movie", "Assets/StreamingAssets/Movie");


            AssetDatabase.Refresh();
            AssetDatabase.SaveAssets();

            string outputPath = string.Format("{0}/{1}/{2}", ResSetting.AssetBundlesOutputPath, ResSetting.GetChannelRes(), v);
            string location   = string.Format("{0}/{1}", outputPath, "TankGirl.apk");

            BuildApk(v, location);


            AssetDatabase.Refresh();
            AssetDatabase.SaveAssets();
        }
コード例 #13
0
ファイル: AndroidTool.cs プロジェクト: jewer3330/fantasy
        public static void BuildAndroidProject(Version v)
        {
            string apkPath  = string.Format("{0}/{1}", ResSetting.AssetBundlesOutputPath, ResSetting.GetChannelRes());
            string location = string.Format("{0}/{1}.Project", apkPath, v);


            FileUtilTool.CreateFolderForFile(location);
            string[] levels = new string[] { BuildTool.startScene };
            try
            {
                EditorUserBuildSettings.exportAsGoogleAndroidProject = true;


                if (BuildTool.isDev)
                {
                    var result = BuildPipeline.BuildPlayer(levels, location, BuildTarget.Android, BuildOptions.ConnectWithProfiler | BuildOptions.Development);
                }
                else
                {
                    var result = BuildPipeline.BuildPlayer(levels, location, BuildTarget.Android, BuildOptions.None);
                }

                if (BuildTool.isDev)
                {
                    var result = BuildPipeline.BuildPlayer(levels, location, BuildTarget.Android, BuildOptions.ConnectWithProfiler | BuildOptions.Development | BuildOptions.AcceptExternalModificationsToPlayer);
                }
                {
                    UnityEditor.PlayerSettings.bundleVersion = v.ToString();
                    var result = BuildPipeline.BuildPlayer(levels, location, BuildTarget.Android, BuildOptions.AcceptExternalModificationsToPlayer);
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError("build android error: " + e.ToString());
                throw new System.Exception(e.ToString());
            }
        }
コード例 #14
0
ファイル: AndroidTool.cs プロジェクト: jewer3330/fantasy
        public static void BuildApkNoGenRes()
        {
            Version v = BuildTool.versionRes;

            FileUtilTool.DeleteFolder("Assets/StreamingAssets/");

            //写入Version文件和写入fullApkIdentify文件
            Version.SaveVersion2StreamingAsset(v);

            //写入配置信息
            //WriteApkConfig();

            //拷贝除apk以外的资源
            ResTool.CopyResToStreaming();


            AssetDatabase.Refresh();
            AssetDatabase.SaveAssets();

            //打包
            string apkPath  = string.Format("{0}/{1}", ResSetting.AssetBundlesOutputPath, ResSetting.GetChannelRes());
            string location = "";

            if (BuildTool.type == BuildTool.BuildType.APK)
            {
                location = string.Format("{0}/{4}/TankGirl{1}({2}).res{3}.apk", apkPath, PlayerSettings.bundleVersion, PlayerSettings.Android.bundleVersionCode, v,
                                         string.Format("{0:yyyyMMddHHmm}", System.DateTime.Now));
            }
            else
            {
                location = string.Format("{0}/TankGirl_AndroidProject/", apkPath);

                string path = location.Replace(@"\", "/");
                if (path.Contains("/"))
                {
                    string dir = path.Substring(0, path.LastIndexOf("/"));
                    DeleteADirectory(dir);
                }
            }

            BuildApk(v, location);


            AssetDatabase.Refresh();
            AssetDatabase.SaveAssets();
        }
コード例 #15
0
        public IEnumerator UpdateRes(List <AssetbundleJsonData> updateFiles)
        {
            download = 0;
            tip      = " 更新资源中 文件个数 " + updateFiles.Count;
            Debug.LogError(tip);
            this.updateFiles = updateFiles;
            UILoadingHelper.Start(1, null);
            int taskNum = 10;

            MultiWWW.instance.Init(20);
            while (MultiWWW.instance.currentDownload < updateFiles.Count)
            {
                if ((downFileCount - MultiWWW.instance.currentDownload) <= (taskNum / 2) && downFileCount < updateFiles.Count)
                {
                    for (int i = 0; i < taskNum; i++)
                    {
                        if (downFileCount < updateFiles.Count)
                        {
                            string urlFile = string.Format("{0}/{1}/{2}", ResSetting.GetChannelRes(), newVersion, updateFiles[downFileCount].resName);
                            MultiWWW.instance.AddJob(urlFile, OnDonwloadResFinish, updateFiles[downFileCount]);
                            downFileCount++;
                        }
                    }
                }

                if (condition)
                {
                    UIMessageBoxHelper.Cancel();
                    if (MultiWWW.instance.current != null)
                    {
                        tip = "下载文件 " + MultiWWW.instance.current.url;
                    }
                    yield return(MultiWWW.instance.StartDownload());
                }

                if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
                {
                    condition = true;
                }

                if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
                {
                    if (ignore4g == false)
                    {
                        condition = false;

                        string msg = "你当前处于运营商网络,下载会产生额外流量,是否继续更新?";
                        UIMessageBoxHelper.Show(msg,
                                                () =>
                        {
                            ignore4g  = true;
                            condition = true;
                        },
                                                () =>
                        {
                            condition = false;
                            ReStart();
                        });
                    }
                }

                if (Application.internetReachability == NetworkReachability.NotReachable)
                {
                    condition = false;
                    string msg = string.Format("网络断开,尝试重连中...");
                    UIMessageBoxHelper.Show(
                        msg,
                        () =>
                    {
                    },
                        () =>
                    {
                        ReStart();
                    });
                }

                if (condition == false)
                {
                    yield return(new WaitForSeconds(2f));
                }
                UILoadingHelper.SetProgress((float)MultiWWW.instance.currentDownload / (float)updateFiles.Count * (resSize / (resSize)));
            }

            UILoadingHelper.SetProgress(resSize / (resSize));
        }