Exemplo n.º 1
0
    bool NewMapFileGUI()
    {
        GUILayout.BeginHorizontal("box");
        newFileName = EditorDrawGUIUtil.DrawBaseValue("新建地图文件", newFileName).ToString();
        if (GUILayout.Button("确定", GUILayout.Width(50)))
        {
            if (ResourcePathManager.ContainsFileName(newFileName))
            {
                EditorUtility.DisplayDialog("错误", "文件名与其他文件重复", "OK");
                return(true);
            }
            MapInfomation info = new MapInfomation();
            info.id = GetMaxID() + 1;
            //info.sceneName = "Scene_" + newFileName;
            info.mapFileName = MapUseConstValues.MapFileNamePrefix + newFileName;
            MapManager.MapInfosDic.Add(info.id, info);

            GlobalEvent.AddEvent(EditorGlobalEventEnum.OnResourcesAssetsChange, (t) =>
            {
                Initialize();
            }, true);
            SaveMapInfoData();

            FileUtils.CreateTextFile(MapUseConstValues.MapDataDirectory + info.mapFileName + "/" + info.mapFileName + ".txt", "");
            AssetDatabase.Refresh();

            return(false);
        }
        GUILayout.EndHorizontal();
        return(true);
    }
Exemplo n.º 2
0
        public static void SaveData(string dataName, string pathName, LogicObjectContainer data)
        {
            string path    = LogicSystemEditorTools.GetPath(dataName, pathName);
            string content = JsonUtils.ClassOrStructToJson(data);

            FileUtils.CreateTextFile(path, content);
            if (!ResourcePathManager.ContainsFileName(dataName))
            {
                ResourcePathManager.Clear();
            }
        }
Exemplo n.º 3
0
    private void CreateUIGUI()
    {
        newUIName = EditorDrawGUIUtil.DrawBaseValue("UI名字:", newUIName).ToString();

        string tempName = newUIName + "Window";

        GUILayout.Label("显示名字:" + tempName);

        GUILayout.Space(5);

        type = (UIType)EditorDrawGUIUtil.DrawBaseValue("UI Type: ", type);
        mode = (UIMode)EditorDrawGUIUtil.DrawBaseValue("UI Mode: ", mode);

        string dis = "";

        if (mode == UIMode.DoNothing)
        {
            dis = "打开该界面时, 不加入backSequence队列";
        }
        if (mode == UIMode.HideOther)
        {
            dis = "打开该界面时, 闭其他队列的界面,加入backSequence队列";
        }
        if (mode == UIMode.NeedBack)
        {
            dis = "打开该界面时,不关闭其他界面,加入backSequence队列";
        }
        EditorGUILayout.HelpBox(dis, MessageType.Info);

        bool isCanUse = true;

        if (ResourcePathManager.ContainsFileName(tempName))
        {
            GUILayout.Space(5);
            isCanUse = false;
            EditorGUILayout.HelpBox("与资源名重复", MessageType.Error);
        }
        if (string.IsNullOrEmpty(newUIName))
        {
            isCanUse = false;
        }

        GUILayout.Label("描述:");
        description = GUILayout.TextArea(description);
        GUILayout.Space(5);
        if (isCanUse && !isCreating && GUILayout.Button("创建"))
        {
            UIName = tempName;
            CreateUI(tempName);
        }
    }
Exemplo n.º 4
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();
        }
    }
Exemplo n.º 5
0
    private static void UpdateAsset(List <string> paths)
    {
        bool isUpdate = false;

        foreach (var item in paths)
        {
            if (item.Contains("Assets/Resources"))
            {
                isUpdate = true;
                break;
            }
        }
        if (isUpdate)
        {
            AssetsSortEidtorWindow.RefreshResData();
            AssetBundleBuildUtils.CreateAllResPathInfo("Assets/Resources");
            ResourcePathManager.Clear();

            GlobalEvent.DispatchEvent(EditorGlobalEventEnum.OnResourcesAssetsChange);
        }
    }
Exemplo n.º 6
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();
        }
    }
Exemplo n.º 7
0
 public string SiteResource(string path)
 {
     return(ResourcePathManager.GetResourcePath(SiteRoot, path));
 }
Exemplo n.º 8
0
        void DrawAllFileGUI()
        {
            List <string> nameList = new List <string>(dataNameDic.Keys);

            if (nameList.Count == 0)
            {
                return;
            }

            GUILayout.BeginHorizontal();
            selectName = EditorDrawGUIUtil.DrawPopup("类型:", selectName, nameList);
            //添加新类型
            if (!isNewOne && GUILayout.Button("+", GUILayout.Width(30)))
            {
                isNewOne = !isNewOne;
            }
            if (isNewOne)
            {
                newName = EditorDrawGUIUtil.DrawBaseValue("新建名字:", newName).ToString();
                if (GUILayout.Button("确定", GUILayout.Width(60)))
                {
                    if (string.IsNullOrEmpty(newName) || ResourcePathManager.ContainsFileName(newName) || dataNameDic[selectName].Contains(newName))
                    {
                        EditorUtility.DisplayDialog("错误", "名字不能重复或为空", "OK");
                        return;
                    }
                    dataNameDic[selectName].Add(newName);
                    isNewOne = false;
                }
                if (GUILayout.Button("取消", GUILayout.Width(60)))
                {
                    isNewOne = false;
                }
            }
            //删除该类型
            if (!isNewOne && GUILayout.Button("-", GUILayout.Width(30)))
            {
                if (EditorUtility.DisplayDialog("警告", "是否删除类型:" + selectName, "OK", "Cancel"))
                {
                    ms.RemoveItem(selectName);
                    Init();
                    return;
                }
            }

            GUILayout.EndHorizontal();

            GUILayout.Space(8);

            scrollViewPos = GUILayout.BeginScrollView(scrollViewPos, true, true);

            foreach (string name in dataNameDic[selectName])
            {
                if (name == editFileName)
                {
                    GUI.color = Color.red;
                }
                GUILayout.BeginVertical("box");
                GUILayout.BeginHorizontal();
                GUILayout.Label("文件名:" + name);
                if (GUILayout.Button("编辑", GUILayout.Width(60)))
                {
                    LogicSystemEditorWindow.ShowWindow(name, selectName);
                    editFileName = name;
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(9);
                if (GUILayout.Button("移除", GUILayout.Width(70)))
                {
                    if (EditorUtility.DisplayDialog("警告", "是否确定删除文件" + name, "OK", "Cancel"))
                    {
                        Debug.Log(name);
                        ResourcePathManager.DeleteResouceFile(name);
                        dataNameDic[selectName].Remove(name);
                    }

                    return;
                }
                GUILayout.EndVertical();

                GUI.color = oldColor;
            }

            GUILayout.EndScrollView();
        }
Exemplo n.º 9
0
    static IEnumerator DownloadUpdateZipFile(string serverFilePath, string fileTempSavePath)
    {
        WWW www = new WWW(serverFilePath);

        yield return(www);

        if (string.IsNullOrEmpty(www.error))
        {
            string tempDir = Path.GetDirectoryName(fileTempSavePath);
            try
            {
                if (!Directory.Exists(tempDir))
                {
                    Directory.CreateDirectory(tempDir);
                }

                FileStream stream   = new FileStream(fileTempSavePath, FileMode.OpenOrCreate);
                byte[]     dataByte = www.bytes;
                stream.Write(dataByte, 0, dataByte.Length);
                stream.Close();
            }catch (Exception e)
            {
                Debug.LogError("文件写入失败:" + e);
            }
            ZipUtils.UnZip(fileTempSavePath, tempDir);
            FileUtils.DeleteFile(fileTempSavePath);

            //string zipFileName = Path.GetFileNameWithoutExtension(fileTempSavePath);

            string tempPathData = FileUtils.LoadTextFileByPath(tempDir + "/UpdatePathFile.txt");
            Dictionary <string, string> pathDaraDic = ResourcePathManager.LoadPathData(tempPathData);

            string tempPathData1 = FileUtils.LoadTextFileByPath(tempDir + "/PathFile.txt");
            Dictionary <string, string> pathDaraDic1 = ResourcePathManager.LoadPathData(tempPathData);

            foreach (string key in pathDaraDic.Keys)
            {
                if (pathDaraDic1.ContainsKey(key))
                {
                    pathDaraDic1[key] = pathDaraDic[key];
                }
                else
                {
                    pathDaraDic1.Add(key, pathDaraDic[key]);
                }

                string oldPath = tempDir + "/" + Path.GetFileName(pathDaraDic[key]);
                string newPath = tempDir + "/" + pathDaraDic[key];
                FileUtils.MoveFile(oldPath, newPath);
            }
            string PathFileData = "";
            foreach (string key in pathDaraDic1.Keys)
            {
                PathFileData += key + "," + pathDaraDic1[key] + "&";
            }
            FileUtils.CreateTextFile(tempDir + "/PathFile.txt", PathFileData);
            FileUtils.DeleteFile(tempDir + "/UpdatePathFile.txt");
        }
        else
        {
            Debug.LogError("DownloadUpdateZipFile error: " + www.error);
        }
        yield return(new WaitForEndOfFrame());
    }
Exemplo n.º 10
0
    private void NewTableConfig()
    {
        GUILayout.BeginHorizontal("box");
        newFileName = EditorDrawGUIUtil.DrawBaseValue("新建配置文件:", newFileName).ToString();
        if (GUILayout.Button("确定", GUILayout.Width(50)))
        {
            if (ResourcePathManager.ContainsFileName(newFileName) || string.IsNullOrEmpty(newFileName))
            {
                EditorUtility.DisplayDialog("警告", "名字不能为空或重复", "OK");
            }
            else
            {
                chooseFileName = newFileName;
                fileNames.Add(newFileName);
            }
        }

        GUILayout.EndHorizontal();

        if (string.IsNullOrEmpty(newFileName))
        {
            return;
        }
        if (ResourcePathManager.ContainsFileName(newFileName))
        {
            EditorGUILayout.HelpBox("文件名重复!!", MessageType.Error);
            return;
        }
        if (newConfigInfo == null)
        {
            newConfigInfo = new TableConfigOtherInfo();
        }

        newConfigInfo.configDescription = EditorDrawGUIUtil.DrawBaseValue("配置文件描述:", newConfigInfo.configDescription).ToString();
        GUILayout.Space(5);
        GUILayout.BeginHorizontal("box");
        GUILayout.Box("添加字段:");
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("+", GUILayout.Width(50)))
        {
            TableConfigFieldInfo f = new TableConfigFieldInfo();
            f.fieldName = "NewField" + newConfigInfo.fieldInfoDic.Count;
            while (newConfigInfo.fieldInfoDic.ContainsKey(f.fieldName))
            {
                f.fieldName += "_0";
            }
            newConfigInfo.fieldInfoDic.Add(f.fieldName, f);
        }
        GUILayout.EndHorizontal();

        DrawFieldData(newConfigInfo);

        if (newConfigInfo.fieldInfoDic.Count > 0 && GUILayout.Button("创建"))
        {
            GlobalEvent.AddEvent(EditorGlobalEventEnum.OnResourcesAssetsChange, (t) =>
            {
                Debug.Log("OnResourcesAssetsChange");
                AssetsSortManagement.SetLayer(newFileName, configLayerName);
                AssetsSortManagement.Save();

                newFileName   = "";
                newConfigInfo = null;
            }, true);
            string content = TableConfigTool.ConfigInfo2TableText(newConfigInfo, null);
            string path    = CreateConfigClassEditor.SaveConfigFilePath + "/" + newFileName + ".txt";
            FileUtils.CreateTextFile(path, content);
            CreateConfigClassEditor.CreateConfigClassFile(content, newFileName);
            AssetDatabase.Refresh();
        }
    }