// 保存预设
    private void SaveSVNToolPrefabs()
    {
        _prefabWrap.prefabs = storedPrefabs;
        File.WriteAllText(filePath, JsonUtility.ToJson(_prefabWrap));

        if (null != m_SelectedPrefab && m_CurrentEditState != EnumSVNToolWindowEditState.VIEW)
        {
            foreach (SVNToolFolder folder in m_SelectedPrefab.contentFolderPath)
            {
                folder.openFolder = true;
            }
        }
        m_CurrentEditState = EnumSVNToolWindowEditState.VIEW;
    }
    private void GUISVNToolOperation()
    {
        // 判断是否读取存储的配置数据
        if (!m_FinishReadData)
        {
            filePath = String.Concat(Application.dataPath, m_SVNToolSourcePath, m_SvnToolUserID, ".json");
            ReadSVNToolPrefabsFromJson(filePath);
            m_CurrentEditState = EnumSVNToolWindowEditState.VIEW;
            m_FinishReadData   = true;
        }

        if (null == storedPrefabs)
        {
            storedPrefabs = new List <SVNToolPrefab>();
        }

        SetSVNToolPrefabGUI();
    }
    private void SetSVNToolPrefabGUI()
    {
        EditorGUILayout.BeginHorizontal(GUILayout.Height(500));

        #region  择预设

        EditorGUILayout.BeginVertical(GUI.skin.box, GUILayout.Width(200));

        // 顶部按钮
        EditorGUILayout.BeginHorizontal(GUILayout.Width(270));

        EditorGUILayout.LabelField("预设选择", GUILayout.Width(100));
        GUILayout.FlexibleSpace();
        if (m_CurrentEditState == EnumSVNToolWindowEditState.EDIT)
        {
            if (GUILayout.Button("注销", GUILayout.Width(50)))
            {
                PlayerPrefs.DeleteKey(SVN_TOOL_USER_ID_PREF_NAME);
                m_SvnToolUserID  = null;
                m_FinishReadData = false;
            }

            if (GUILayout.Button("新增", GUILayout.Width(50)))
            {
                Int32 largeID = 1;
                // 拿到最大的ID
                foreach (SVNToolPrefab storedPrefab in storedPrefabs)
                {
                    largeID = Math.Max(largeID, storedPrefab.ID);
                }

                m_SelectedPrefab = new SVNToolPrefab(largeID + 1);
                storedPrefabs.Add(m_SelectedPrefab);
            }

            GUI.enabled = SetIfCurrentActionEnableBySelected();
            if (GUILayout.Button("删除", GUILayout.Width(50)))
            {
                storedPrefabs.Remove(m_SelectedPrefab);
                m_SelectedPrefab = null;
            }

            GUI.enabled = true;

            if (GUILayout.Button("保存", GUILayout.Width(50)))
            {
                SaveSVNToolPrefabs();
                // 刷新状态
                InitSyncSVNToolPrefabStatus();
            }
        }
        else if (m_CurrentEditState == EnumSVNToolWindowEditState.VIEW)
        {
            if (GUILayout.Button("开启配置", GUILayout.Width(70)))
            {
                m_CurrentEditState = EnumSVNToolWindowEditState.EDIT;
                if (null != m_SelectedPrefab)
                {
                    foreach (SVNToolFolder folder in m_SelectedPrefab.contentFolderPath)
                    {
                        folder.openFolder = false;
                    }
                }
            }
        }

        EditorGUILayout.EndHorizontal();

        // 展示预设内容列表
        leftScrollPos = EditorGUILayout.BeginScrollView(leftScrollPos, GUI.skin.box);
        {
            for (int i = 0; i < storedPrefabs.Count; i++)
            {
                SVNToolPrefab currentPrefab = storedPrefabs[i];
                if (null != m_SelectedPrefab && m_SelectedPrefab.ID == currentPrefab.ID)
                {
                    SetOnSelectedBackgroundColor();
                }

                EditorGUILayout.BeginHorizontal(GUI.skin.box);
                {
                    GUI.backgroundColor = Color.white;

                    Boolean preSelected = currentPrefab.ifSelected;
                    Boolean ifChanged   = false;
                    currentPrefab.ifSelected = GUILayout.Toggle(currentPrefab.ifSelected, "同步", GUILayout.Width(40));
                    if (preSelected != currentPrefab.ifSelected)
                    {
                        // 如果选择了不同的同步规则,则保存
                        SaveSVNToolPrefabs();
                        // 刷新已选Data
                        ifChooseDataDirty = true;
                        ifChanged         = true;

                        if (currentPrefab.ifSelected)
                        {
                            DoSyncSVNToolPrefabStatus(currentPrefab, false);
                        }
                    }

                    // 预设名
                    if (m_CurrentEditState == EnumSVNToolWindowEditState.EDIT)
                    {
                        currentPrefab.name = EditorGUILayout.TextField(currentPrefab.name, GUILayout.Width(120));
                    }
                    else if (m_CurrentEditState == EnumSVNToolWindowEditState.VIEW)
                    {
                        EditorGUILayout.LabelField(currentPrefab.name, GUILayout.Width(120));
                    }

                    if (ifChanged)
                    {
                        GUI.FocusControl("zero");
                    }

                    GUILayout.FlexibleSpace();
                    if (null != currentPrefab.name && currentPrefab.name.Equals("Global") &&
                        null != m_SvnToolUserID &&
                        !m_SvnToolUserID.Equals("Global") &&
                        m_CurrentEditState == EnumSVNToolWindowEditState.EDIT)
                    {
                        if (GUILayout.Button("恢复", GUILayout.Width(40)))
                        {
                            DoRestoreGlobalPrefab(currentPrefab);
                        }
                    }
                    if (GUILayout.Button("查看", GUILayout.Width(40)))
                    {
                        SelectCurrentSVNToolPrefab(currentPrefab);
                    }
                }

                EditorGUILayout.EndHorizontal();

                SetDefaultSVNToolBackgroundColor();
            }
        }
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();

        #endregion

        #region 预设与配置主体

        EditorGUILayout.BeginVertical(GUI.skin.box);

        EditorGUILayout.BeginHorizontal();

        GUIStyle redGUISkin = new GUIStyle();
        redGUISkin.fontSize         = 14;
        redGUISkin.normal.textColor = Color.red;
        if (m_CurrentEditState == EnumSVNToolWindowEditState.EDIT)
        {
            EditorGUILayout.LabelField("预设配置");
            GUILayout.Label(null == m_SelectedPrefab ? "需要左侧选择目标预设" : "拖拽文件/文件夹到下方即可添加", redGUISkin);
        }
        else if (m_CurrentEditState == EnumSVNToolWindowEditState.VIEW)
        {
            EditorGUILayout.LabelField("配置文件");
            GUILayout.FlexibleSpace();
            if (CheckIfSelectedPrefabSyncing())
            {
                GUILayout.Label("同步中...", redGUISkin);
            }

            GUI.enabled = !CheckIfSelectedPrefabSyncing();
            if (GUILayout.Button("刷新同步"))
            {
                m_SelectedPrefab.initedFileStatus = false;
                DoSyncSVNToolPrefabStatus(m_SelectedPrefab);
            }

            GUI.enabled = true;
        }
        EditorGUILayout.EndHorizontal();

        // 设定ScrollView为一个Control对象
        GUI.SetNextControlName("text:");
        rightScrollPos = EditorGUILayout.BeginScrollView(rightScrollPos, GUI.skin.box);
        {
            if (null != m_SelectedPrefab)
            {
                // 当前是否在进行同步
                if (CheckIfSelectedPrefabSyncing())
                {
                    GUILayout.Label("加载中");
                }
                else
                {
                    #region 显示文件夹

                    for (int i = 0; i < m_SelectedPrefab.contentFolderPath.Count; i++)
                    {
                        SVNToolFolder folder = m_SelectedPrefab.contentFolderPath[i];
                        EditorGUILayout.BeginVertical(GUI.skin.box);
                        {
                            EditorGUILayout.BeginHorizontal();
                            {
                                // 配置状态
                                if (m_CurrentEditState == EnumSVNToolWindowEditState.EDIT)
                                {
                                    EditorGUILayout.LabelField("【文件夹】\t" + folder.name, GUILayout.Width(m_RightPathTextLength));
                                    GUILayout.FlexibleSpace();
                                    if (GUILayout.Button("打开文件夹", GUILayout.Width(100)))
                                    {
                                        UESvnOperation.GetSvnOperation().ShowFileInExplorer(folder.path);
                                    }
                                    if (GUILayout.Button("Del", GUILayout.Width(30)))
                                    {
                                        m_SelectedPrefab.contentFolderPath.Remove(folder);
                                    }
                                }
                                else if (m_CurrentEditState == EnumSVNToolWindowEditState.VIEW)
                                {
                                    GUI.enabled = folder.contentNeedSyncFiles.Count > 0;
                                    if (folder.existNewFileOrFolder)
                                    {
                                        SetSVNToolFolderSelectedParyColor();
                                        if (GUILayout.Button("存在新建,以及文件夹操作,请点击此处", GUILayout.Width(220)))
                                        {
                                            UESvnOperation.GetSvnOperation().CommitFile(folder.path);
                                            InitSyncSVNToolPrefabStatus();
                                        }
                                        SetDefaultSVNToolBackgroundColor();
                                    }

                                    // 浏览模式 - 仅展示需同步文件
                                    if (folder.GetSVNToolFileCurrentSyncState() == EnumSVNToolFolderNeedSyncState.SELECTED_ALL)
                                    {
                                        SetSVNToolFileCanBeCommitColor();
                                    }
                                    else if (folder.GetSVNToolFileCurrentSyncState() == EnumSVNToolFolderNeedSyncState.SELECTED_PART)
                                    {
                                        SetSVNToolFolderSelectedParyColor();
                                    }

                                    Int32 selectedFolderFileCount = folder.GetTotalSelectedSVNToolFiles().Count;

                                    if (GUILayout.Button(selectedFolderFileCount == 0 ? "全选" : "取消选择", GUILayout.Width(60)))
                                    {
                                        // 全选
                                        if (selectedFolderFileCount == 0)
                                        {
                                            foreach (SVNToolFile file in folder.contentNeedSyncFiles)
                                            {
                                                file.ifSelected = true;
                                            }
                                        }
                                        else
                                        {
                                            foreach (SVNToolFile file in folder.contentNeedSyncFiles)
                                            {
                                                file.ifSelected = false;
                                            }
                                        }

                                        ifChooseDataDirty = true;
                                        GUI.FocusControl("zero");    // 取消聚焦,防止选中“当前已选择”后不刷新
                                    }

                                    EditorGUILayout.LabelField("已选 " + selectedFolderFileCount + "/" + folder.contentNeedSyncFiles.Count, GUILayout.Width(70));
                                    SetDefaultSVNToolBackgroundColor();
                                    folder.openFolder = EditorGUILayout.Foldout(folder.openFolder, folder.name, true);

                                    GUI.enabled = true;

                                    if (GUILayout.Button("打开文件夹", GUILayout.Width(100)))
                                    {
                                        UESvnOperation.GetSvnOperation().ShowFileInExplorer(folder.path);
                                    }
                                }
                            }
                            EditorGUILayout.EndHorizontal();

                            if (folder.openFolder)
                            {
                                EditorGUILayout.BeginVertical();
                                {
                                    //折叠开关开启时需要显示的内容
                                    foreach (SVNToolFile file in folder.contentNeedSyncFiles)
                                    {
                                        EditorGUILayout.BeginHorizontal(GUI.skin.box);
                                        {
                                            SVNToolWindowWriteFileField(file);
                                        }
                                        EditorGUILayout.EndHorizontal();
                                    }
                                }
                                EditorGUILayout.EndVertical();
                            }
                        }
                        EditorGUILayout.EndVertical();
                    }

                    #endregion

                    #region 显示文件

                    for (int i = 0; i < m_SelectedPrefab.contentFilePath.Count; i++)
                    {
                        SVNToolFile file = m_SelectedPrefab.contentFilePath[i];
                        if (m_CurrentEditState == EnumSVNToolWindowEditState.VIEW && !file.CanBeCommit)
                        {
                            continue;
                        }

                        EditorGUILayout.BeginHorizontal(GUI.skin.box);
                        {
                            // 编辑模式
                            if (m_CurrentEditState == EnumSVNToolWindowEditState.EDIT)
                            {
                                EditorGUILayout.LabelField("【 文 件 】\t" + file.name, GUILayout.Width(m_RightPathTextLength));
                                GUILayout.FlexibleSpace();
                                if (GUILayout.Button("Del", GUILayout.Width(30)))
                                {
                                    m_SelectedPrefab.contentFilePath.Remove(file);
                                }
                            }
                            // 浏览模式
                            else if (m_CurrentEditState == EnumSVNToolWindowEditState.VIEW)
                            {
                                SVNToolWindowWriteFileField(file);
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }

                    #endregion
                }
            }
        }
        EditorGUILayout.EndScrollView();

        #region 添加拖拽事件

        var rect = GUILayoutUtility.GetLastRect();
        //如果鼠标正在拖拽中或拖拽结束时,并且鼠标所在位置在文本输入框内
        if ((Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragPerform) &&
            m_CurrentEditState == EnumSVNToolWindowEditState.EDIT &&
            null != m_SelectedPrefab &&
            rect.Contains(Event.current.mousePosition)
            )
        {
            //改变鼠标的外表
            DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
            if (Event.current.type == EventType.DragPerform &&
                DragAndDrop.paths != null &&
                DragAndDrop.paths.Length > 0
                )
            {
                AddNewSVNToolPath(DragAndDrop.paths);
                // 保存
                //                SaveSVNToolPrefabs();
            }
        }

        #endregion

        EditorGUILayout.EndVertical();

        #endregion

        EditorGUILayout.EndHorizontal();

        #region 结果列表

        if (CheckIfSelectedPrefabSyncing())
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                GUILayout.Label("加载中");
            }
            EditorGUILayout.EndVertical();
        }
        else if (m_CurrentEditState == EnumSVNToolWindowEditState.EDIT)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                GUILayout.Label("编辑中");
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            // TODO 刷新值修改为 - 当做了选择后进行的刷新
            if (ifChooseDataDirty)
            {
                RefreshAllSelectedSVNToolFiles();    // 刷新值
            }

            #region 未选择结果列表

            GUILayout.Label("配置文件未选择");

            hideScrollPos = EditorGUILayout.BeginScrollView(hideScrollPos, GUI.skin.box, GUILayout.MaxHeight(100));
            {
                EditorGUILayout.TextArea(hideChooseResult, GUILayout.Height(100));
            }
            EditorGUILayout.EndScrollView();

            #endregion

            #region 已选结果列表

            GUILayout.Label("当前已选择");

            showScrollPos = EditorGUILayout.BeginScrollView(showScrollPos, GUI.skin.box, GUILayout.MaxHeight(300));
            {
                EditorGUILayout.TextArea(showChooseResult, GUILayout.Height(300));
            }
            EditorGUILayout.EndScrollView();

            #endregion
        }

        #endregion

        #region 操作组

        // 控制提交按钮的可控
        GUI.enabled = m_CurrentEditState != EnumSVNToolWindowEditState.EDIT && !CheckIfSelectedPrefabSyncing();

        EditorGUILayout.BeginHorizontal();
        {
            if (GUILayout.Button("提交"))
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (SVNToolFile file in showResult)
                {
                    stringBuilder.Append(file.path).Append("*");
                }
                UESvnOperation.GetSvnOperation().CommitFile(stringBuilder.ToString());
                InitSyncSVNToolPrefabStatus();
            }
        }
        EditorGUILayout.EndHorizontal();

        GUI.enabled = true;

        #endregion
    }