Ejemplo n.º 1
0
        public override void OnGUI(Rect position)
        {
            CustomerHeaderAttribute headAttribute = (CustomerHeaderAttribute)attribute;  //获取自定义的标签
            Color color = ColorExpand.HtmToColor(headAttribute.m_Color);

            #region 重绘GUI
            position = EditorGUI.IndentedRect(position);
            style.normal.textColor = color;
            GUI.Label(position, headAttribute.m_Ttitle, style);
            #endregion
        }
Ejemplo n.º 2
0
        private void OnGUI()
        {
            GUILayout.Space(5);
            GUILayout.BeginVertical("box");

            #region Excel 配置信息
            GUILayout.Space(5);
            GUILayout.BeginVertical("box");

            GUILayout.BeginHorizontal();
            GUILayout.Label("需要解析的Excel路径:", GUILayout.Width(150));
            mLocalizationConfigExcelPath = GUILayout.TextField(mLocalizationConfigExcelPath, GUILayout.Width(Screen.width - 260));
            if (GUILayout.Button("选择Excel", GUILayout.Width(80)))
            {
                string selectExcelPath = EditorUtility.OpenFilePanel("选择本地化Excel 文件", mLocalizationConfigExcelPath, "*.*");
                if (string.IsNullOrEmpty(selectExcelPath) == false)
                {
                    mLocalizationConfigExcelPath = selectExcelPath;
                    PlayerPrefsManager.SetString(EditorPlayerPrefsKeyDefine.S_LastSelectLocalizationExcelPath, mLocalizationConfigExcelPath);
                    Debug.Log("选择本地化Excel 路径为:" + selectExcelPath);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(3);
            GUIStyle rulerGUIStyle = new GUIStyle();
            rulerGUIStyle.normal.textColor = ColorExpand.HtmToColor("#1B7AD4");
            GUILayout.Label("Excel 中第一行为支持的本地化语言key,对应Language 枚举中的有效字符串", rulerGUIStyle);
            GUILayout.Space(2);
            GUILayout.Label("Excel 中第二行为本地户内容的格式,默认是<color=#FF0000>string </color> 类型", rulerGUIStyle);
            GUILayout.Space(2);
            GUILayout.Label(string.Format("Excel 中第一列的Key 必须以<color=#FF0000> {0}</color> 开头,否则会检测到格式错误", ConstDefine.S_LocalizationKeyFlag), rulerGUIStyle);
            GUILayout.EndVertical();
            #endregion

            #region 导出配置
            GUILayout.Space(5);
            GUILayout.BeginVertical("box");

            GUILayout.BeginHorizontal();
            GUILayout.Label("Excel中导出指定的语言:", GUILayout.Width(150));
            Language selectedLanguage = (Language)EditorGUILayout.EnumFlagsField(mExportLanguageType, GUILayout.Width(Screen.width - 180));
            if (selectedLanguage != mExportLanguageType)
            {
                Debug.LogEditorInfor("切换导出语言为 " + selectedLanguage);
                mExportLanguageType = selectedLanguage;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Excel中导出指定的格式:", GUILayout.Width(150));
            ExportFormatEnum selectedFromat = (ExportFormatEnum)EditorGUILayout.EnumFlagsField(mExportFormatType, GUILayout.Width(Screen.width - 180));
            if (selectedFromat != mExportFormatType)
            {
                Debug.LogEditorInfor("切换导出格式为 " + selectedFromat);
                mExportFormatType = selectedFromat;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Excel中导出的配置保存目录:", GUILayout.Width(150));
            GUILayout.TextField(mLocalizationConfigExcelExportPath, GUILayout.Width(Screen.width - 180));
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
            #endregion


            #region 功能接口
            GUILayout.Space(5);
            GUILayout.BeginVertical("box");

            #region 检测Excel 文件
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("检测Excel 文件格式", GUILayout.Height(35)))
            {
                LoadLocalizationExcel();
                CheckExcelLocalizationKey();
            }
            if (GUILayout.Button("Excel 导出指定语言的配置文件", GUILayout.Height(35)))
            {
                if (mIsFormatEnable == false)
                {
                    Debug.LogError(string.Format("请确保先进行了格式检测并且没有格式错误!!"));
                    return;
                }

                if (mExportLanguageType == 0)
                {
                    Debug.LogError("没有选择需要导出的语言");
                    return;
                }
                if (mExportFormatType == 0)
                {
                    Debug.LogError("没有选择需要导出的格式");
                    return;
                }

                List <Language> allLanguages = EnumUtility.GetEnumValue <Language>();
                if ((int)mExportLanguageType != -1)
                {
                    for (int dex = allLanguages.Count - 1; dex >= 0; dex--)
                    {
                        if ((allLanguages[dex] & mExportLanguageType) != allLanguages[dex])
                        {
                            allLanguages.RemoveAt(dex);
                        }
                    }
                }

                List <ExportFormatEnum> allexportFormats = EnumUtility.GetEnumValue <ExportFormatEnum>();
                if ((int)mExportFormatType != -1)
                {
                    for (int dex = allexportFormats.Count - 1; dex >= 0; dex--)
                    {
                        if ((allexportFormats[dex] & mExportFormatType) != allexportFormats[dex])
                        {
                            allexportFormats.RemoveAt(dex);
                        }
                    }
                }

                ExportExcel(allLanguages, allexportFormats);
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            #endregion

            GUILayout.EndVertical();
            #endregion

            GUILayout.EndVertical();
        }