public static void StartLoadResource(CallBack completeCallBack)
 {
     AssetData[] ads = ResourcesManager.LoadAssetsByName("AssetBundleInfo");
     if (ads.Length > 0)
     {
         TextAsset tx = ads[0].asset as TextAsset;
         Dictionary <string, object> tempDic = InternalConfigManager.LoadData(tx.text);
         string        s         = tempDic["preLoadResPaths"].ToString();
         List <string> pathNames = tempDic["preLoadResPaths"] as List <string>;
         int           count     = pathNames.Count;
         ResourcesManager.LoadManyAssetAsyncByName(pathNames, (num) =>
         {
             int left = count - num + 1;
             //Debug.LogError("Left :" + num);
             if (progressCallBack != null)
             {
                 progressCallBack(count, count - num);
             }
             if (showContentCallBack != null)
             {
                 string ss = "Preload(" + (count - num) + " / " + count + ")";
                 showContentCallBack(ss);
             }
         }, completeCallBack);
     }
     else
     {
         if (completeCallBack != null)
         {
             completeCallBack();
         }
     }
 }
        public void Read_IfFileNotExists_ReturnsNull()
        {
            // arrange

            var Application = GetApllicationMock();
            var File = GetFileWrapMock(false);
            InternalConfigManager Manager = new InternalConfigManager(File.Object, Application.Object);
            // action
            var Date = Manager.GetMaxDate();
            // assert
            Assert.IsNull(Date);
        }
        public void Read_IfFileIsEmpty_ReturnsNull()
        {
            // arrange

            var Application = GetApllicationMock();
            var File = GetFileWrapMock(false);
            File.Setup(s => s.ReadAllLines(@"C:\archivos de programa\test\maxdate.txt")).Returns(new string[] {});
            InternalConfigManager Manager = new InternalConfigManager(File.Object, Application.Object);
            // action
            var Date = Manager.GetMaxDate();
            // assert
            Assert.IsNull(Date);
        }
        public void Read_IfFileExists_ReturnsDate()
        {
            // arrange
            var File = GetFileWrapMock(true);
            var Application = GetApllicationMock();

            File.Setup(s => s.ReadAllLines(@"C:\archivos de programa\test\maxdate.txt")).Returns(new[] {@"07/08/2013"});
            InternalConfigManager Manager = new InternalConfigManager(File.Object, Application.Object);
            // action
            var Date = Manager.GetMaxDate();
            // assert
            Assert.AreEqual(DateTime.Parse("08/07/2013 00:00"), Date.Value);
        }
        public void Save_WhenEnds_SaveMaxDate()
        {
            // arrange
            var File = GetFileWrapMock(true);
            var Application = GetApllicationMock();

            File.Setup(s => s.WriteAllLines(@"C:\archivos de programa\test\maxdate.txt",new [] {@"08/07/2013 00:00:00"}));
            InternalConfigManager Manager = new InternalConfigManager(File.Object, Application.Object);
            DateTime DateTimeToSave = DateTime.Parse("08/07/2013");
            // action
            bool Saved = Manager.SaveDate(DateTimeToSave);
            // assert
            Assert.IsTrue(Saved);
            File.Verify (m=>m.WriteAllText(@"C:\archivos de programa\test\maxdate.txt",@"07/08/2013 00:00:00"), Times.Once ());
        }
Esempio n. 6
0
    void SetGameSetting()
    {
        InternalConfigManager.ReleaseAll();
        ResourcesManager.ReleaseAll();
        ResourcePathManager.ReLoadData();
        GameSettingStoreManager.Clear();
        Debug.unityLogger.logEnabled = GameSettingStoreManager.GetValue("Debug", true);
        Application.runInBackground  = GameSettingStoreManager.GetValue("runInBackground", true);

        if (assetsLoadType == AssetsLoadType.AssetBundle)
        {
            PreLoadResourceController.StartLoadResource(IntoGameScene);
        }
        else
        {
            IntoGameScene();
        }
    }
Esempio n. 7
0
    void ChooseFile()
    {
        GUILayout.BeginHorizontal();
        lastChooseFileName = chooseFileName;
        chooseFileName     = EditorDrawGUIUtil.DrawPopup("选择文件", chooseFileName, fileNames);
        if (GUILayout.Button("删除", GUILayout.Width(50)))
        {
            if (EditorUtility.DisplayDialog("警告", "是否删除文件[" + chooseFileName + "]", "确定", "取消"))
            {
                fileNames.Remove(chooseFileName);
                FileUtils.DeleteFile(pathDic + "/" + chooseFileName + ".txt");
                AssetDatabase.Refresh();
                return;
            }
        }
        if (lastChooseFileName != chooseFileName)
        {
            if (string.IsNullOrEmpty(chooseFileName))
            {
                return;
            }
            fileContent = InternalConfigManager.GetConfig(chooseFileName);
        }
        GUILayout.EndHorizontal();

        GUILayout.Space(8);

        List <string> keys = new List <string>(fileContent.Keys);

        scrollViewPos = GUILayout.BeginScrollView(scrollViewPos, "box");
        foreach (string key in keys)
        {
            GUILayout.BeginHorizontal("box");
            fileContent[key] = EditorDrawGUIUtil.DrawBaseValue(key, fileContent[key]);
            if (GUILayout.Button("-", GUILayout.Width(50)))
            {
                fileContent.Remove(key);
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(8);
        }
        GUILayout.EndScrollView();
    }
Esempio n. 8
0
    private void OnGUI()
    {
        toolbarOption = GUILayout.Toolbar(toolbarOption, toolbarTexts);
        switch (toolbarOption)
        {
        case 0:
            GUILayout.BeginHorizontal("box");
            newFileName = EditorDrawGUIUtil.DrawBaseValue("新建配置文件", newFileName).ToString();
            if (GUILayout.Button("确定", GUILayout.Width(50)))
            {
                if (ResourcePathManager.ContainsFileName(newFileName))
                {
                    EditorUtility.DisplayDialog("错误", "文件名与其他文件重复", "OK");
                    return;
                }
                InternalConfigManager.SaveData(pathDic + "/" + newFileName + ".txt", new Dictionary <string, object>());
                AssetDatabase.Refresh();
                Initialize();
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(10);
            break;

        case 1:
            AddNewValueGUI();
            break;
        }

        ChooseFile();

        if (GUILayout.Button("保存"))
        {
            InternalConfigManager.SaveData(pathDic + "/" + chooseFileName + ".txt", fileContent);
            AssetDatabase.Refresh();
        }
    }
Esempio n. 9
0
    static IEnumerator Updating(CallBack completCalback)
    {
        //加载沙河路径下的AssetBundleInfo
        string assetBundleInfoPer    = FileUtils.LoadTextFileByPath(PathDir + "/AssetBundleInfo.txt");
        string assetBundleInfoStream = "";
        string tempAbInfoPath        = OtherUtils.GetWWWLoadPath(Application.streamingAssetsPath + "/AssetBundleInfo.txt");

        //加载StreamAssets下的AssetBundleInfo
        yield return(FileUtils.LoadTxtFileIEnumerator(tempAbInfoPath, (data) => { assetBundleInfoStream = data; }));

        string bundleVersion     = "";
        int    updatePackVersion = 0;

        Debug.Log("加载StreamAssets下的AssetBundleInfo :" + assetBundleInfoStream);
        Dictionary <string, object> tempDic = InternalConfigManager.LoadData(assetBundleInfoStream);

        bundleVersion = tempDic["bundleVersion"].ToString();

        if (!string.IsNullOrEmpty(assetBundleInfoPer))
        {
            Dictionary <string, object> dic = InternalConfigManager.LoadData(assetBundleInfoPer);
            string streamver1    = dic["updatePackVersion"].ToString();
            string bunStreamVer1 = dic["bundleVersion"].ToString();

            if (bundleVersion == bunStreamVer1)
            {
                updatePackVersion = int.Parse(streamver1.Split('-')[2]);
            }
        }
        Debug.Log("updatePackVersion: " + updatePackVersion);

        string updatePackData = "";

        showContentCallBack("Download UpdatePackData");
        //服务器下载updatePackData
        yield return(FileUtils.LoadTxtFileIEnumerator(serverPath + "/" + platform + "/updatePackData.txt", (data) => { updatePackData = data; }));

        List <string> upVerList = new List <string>();

        Debug.Log("服务器下载updatePackData :" + updatePackData);
        if (!string.IsNullOrEmpty(updatePackData))
        {
            Dictionary <string, object> updatePackDataDic = InternalConfigManager.LoadData(updatePackData);
            if (updatePackDataDic.ContainsKey(bundleVersion))
            {
                List <string> upVerListTemp = (List <string>)updatePackDataDic[bundleVersion];

                for (int i = 0; i < upVerListTemp.Count; i++)
                {
                    int temp = int.Parse(upVerListTemp[i].Split('-')[2]);
                    if (temp > updatePackVersion)
                    {
                        Debug.Log("updatePackVersion : " + updatePackVersion + "  upVerListTemp[i]:" + upVerListTemp[i]);
                        upVerList.Add(upVerListTemp[i]);
                    }
                }
            }
        }

        for (int i = 0; i < upVerList.Count; i++)
        {
            int    count            = upVerList.Count;
            string serverFilePath   = serverPath + "/" + platform + "/" + bundleVersion + "/" + upVerList[i] + "/" + upVerList[i] + ".zip";
            string fileTempSavePath = PathDir + "/" + upVerList[i] + ".zip";
            showContentCallBack("Download Update Pack:" + upVerList[i]);
            progressCallBack(count, i + 1);
            Debug.Log("更新包:" + serverFilePath);
            yield return(DownloadUpdateZipFile(serverFilePath, fileTempSavePath));
        }
        yield return(new WaitForEndOfFrame());

        Debug.Log("更新完成");
        if (completCalback != null)
        {
            completCalback();
        }
    }