/// <summary> /// 刷新显示 /// </summary> /// <param name="_userVo"></param> public void refreshView(UserVoBasic _userVo) { mUserVo = _userVo; AboutMeTF.text = mUserVo.UserAboutMe; AboutMeTF.enabled = mManager.isSelf; AboutMeTF.onEndEdit.AddListener(onSetAboutMeHandle); mLevelTF.text = "Lv " + SelfPlayerData.Level; string key = I18NConfig.getCityFlagByInt(mUserVo.UserCountry); mCityFlag.sprite = Resources.Load <Sprite>("CityFlag/" + key + ""); Vector3 cityPosition = mCityFlag.transform.position; cityPosition.z += 5; mCityFlag.transform.position = cityPosition; //if (mUserVo.UserIconUrl.IndexOf("http:") != -1) //{ // AsyncImageDownload.GetInstance().SetAsyncImage(mUserVo.UserIconUrl, mHeadImg); //} //else if (mUserVo.UserIconUrl.IndexOf("Avatar") != -1) //{ // var sprite = Resources.Load<Sprite>("UI/_Avatars/" + mUserVo.UserIconUrl); // mHeadImg.sprite = sprite; //} refreshViewSub(); }
private static void refreshData() { mConfig = XConfig.GetConfig <I18NConfig>(I18NConst.ConfigPath_Resources, AssetLoadType.Resources, false); if (mConfig != null) { mConfig_SerObj = new SerializedObject(mConfig); } mDataRefreshed = true; }
private static void OnConfigFileChanged(string path, AssetInputHandle.ResChangeType type) { if (type == AssetInputHandle.ResChangeType.CreateOrModify) { mCurConfig = TinaX.Config.GetTinaXConfig <I18NConfig>(TinaX.Conf.ConfigPath.i18n); if (mCurConfig != null) { RefreshLanguageFiles(); } } }
static XI18NCacheEditor() { //添加配置文件到资源监听 AssetInputHandle.AddAssetListener("Assets/Resources/" + TinaX.Setup.Framework_Config_Path + "/" + TinaX.Conf.ConfigPath.i18n, OnConfigFileChanged); mCurConfig = TinaX.Config.GetTinaXConfig <I18NConfig>(TinaX.Conf.ConfigPath.i18n); if (mCurConfig != null) { RefreshLanguageFiles(); } }
/************************************************Unity方法与事件***********************************************/ protected override void Start() { base.Start(); videoPlayer.loopPointReached += (VideoPlayer source) => { bMovieEnd = true; }; BuglyUtil.Init(); videoPlayer.Prepare(); MissionConifg.LoadMissionConfig(); propertyConfig.LoadPropertyConfig(); TaskConifg.LoadTaskData(); ItemConifg.LoadItemsConfig(); TreasureBoxConfig.LoadTreasureBoxConfig(); iconManager.OnlyLoadSelf(); RoleConifg.LoadRoleConfig(); LanConfig.LoadLanConfig(); FontConfig.LoadFontConfig(); I18NConfig.LoadResConfig(); AccessoryConfig.LoadAccessoryConfig(); AwardConfig.LoadAwardConfig(); ActionConifg.LoadActionConfig(); LevelConifg.LoadLevelConfig(); SoundConfig.LoadSoundConfig(); imageProgress.fillAmount = 0; GuLog.Debug("<><Preload>Load Begin!"); StartCoroutine(StartLoading()); #if CLEAR_DATA LocalDataManager.getInstance().deleteAll(); #endif mHeartbearActionManager.addEventListener(mUploadFreindHeatbeatAction); mHeartbearActionManager.addEventListener(mUploadintakeHeatbeatAction); mHeartbeatManager.setHeartbeatListener(() => { GuLog.Debug("Preload start do heart beat"); mHeartbearActionManager.startHeartbeat(); }); }
public override void OnInspectorGUI() { this.serializedObject.Update(); EditorGUILayout.LabelField("Text"); // csv path GUILayout.BeginHorizontal(); GUILayout.Label("csv path", GUILayout.Width(50)); EditorGUILayout.PropertyField(this.serializedObject.FindProperty("originCsvFilePath"), new GUIContent("")); GUILayout.EndHorizontal(); this.languages.isExpanded = EditorGUILayout.Foldout(this.languages.isExpanded, "languages"); if (this.languages.isExpanded) { this.languageList.DoLayoutList(); } // ui GUILayout.BeginHorizontal(); GUILayout.Label("ui", GUILayout.Width(50)); EditorGUILayout.PropertyField(this.serializedObject.FindProperty("uiPrefabRootPath"), new GUIContent("")); EditorGUILayout.PropertyField(this.uiTextRegex, new GUIContent("")); GUILayout.EndHorizontal(); // script GUILayout.BeginHorizontal(); GUILayout.Label("script", GUILayout.Width(50)); EditorGUILayout.PropertyField(this.serializedObject.FindProperty("scriptFileRootPath"), new GUIContent("")); EditorGUILayout.PropertyField(this.scriptRegex, new GUIContent("")); GUILayout.EndHorizontal(); // EditorGUILayout.PropertyField(this.refFontRegex); EditorGUILayout.PropertyField(this.refImageRegex); // generate button EditorGUILayout.Space(); if (GUILayout.Button("Generate origin csv file")) { this.GenerateOriginCsvFile(false); } if (GUILayout.Button("Regenerate origin csv file")) { this.GenerateOriginCsvFile(true); } // translate EditorGUILayout.Space(); var curLanguage = I18NConfig.Instance.Language; int curLanguageIndex = 0; string[] languageNames = new string[this.languages.arraySize]; for (int i = 0; i < this.languages.arraySize; i++) { var stringValue = this.languages.GetArrayElementAtIndex(i).FindPropertyRelative("name").stringValue; // record languageNames[i] = stringValue; // match if (stringValue == curLanguage) { curLanguageIndex = i; } } var newLanguageIndex = EditorGUILayout.Popup(curLanguageIndex, languageNames); if (newLanguageIndex != curLanguageIndex) { I18NConfig config = AssetDatabase.LoadAssetAtPath <I18NConfig>("Assets/Game/I18N/I18NConfig.asset"); if (config == null) { Debug.LogError("can not load i18nconfig"); return; } config.Language = languageNames[newLanguageIndex]; EditorUtility.SetDirty(config); I18NConfig.Instance.Language = languageNames[newLanguageIndex]; } if (GUILayout.Button("translate")) { if (!ReplaceResource()) { Debug.LogError("translate stop, break by replace resource"); return; } if (!TranslatePrefabText()) { Debug.LogError("translate stop, break by translate prefab text"); return; } if (!GenerateLuaTable()) { Debug.LogError("translate stop, break by generate lua table"); return; } } this.isExpandTranslateStep = EditorGUILayout.Foldout(this.isExpandTranslateStep, "translate steps"); if (this.isExpandTranslateStep) { if (GUILayout.Button("replace resource")) { ReplaceResource(); } if (GUILayout.Button("translate prefab")) { TranslatePrefabText(); } if (GUILayout.Button("generate lua table")) { GenerateLuaTable(); } } if (GUILayout.Button("generate filter lua table")) { if (!GenerateFilterLuaTable("config_chatfilter", "translate_chatfilter.csv")) { Debug.LogError("generate chat filter faild"); } if (!GenerateFilterLuaTable("config_usernamefilter", "translate_usernamefilter.csv")) { Debug.LogError("generate name filter faild"); } } // this.serializedObject.ApplyModifiedProperties(); }
public static SettingsProvider XI18NSetting() { return(new SettingsProvider(I18NEditorConst.ProjectSetting_Node, SettingsScope.Project, new string[] { "Nekonya", "TinaX", "I18N", "TinaX.I18N", "Localization" }) { label = "X I18N", guiHandler = (searchContent) => { if (!mDataRefreshed) { refreshData(); } EditorGUILayout.BeginVertical(Styles.body); if (mConfig == null) { GUILayout.Space(20); GUILayout.Label(I18Ns.NoConfig); if (GUILayout.Button(I18Ns.BtnCreateConfigFile, Styles.style_btn_normal, GUILayout.MaxWidth(120))) { mConfig = XConfig.CreateConfigIfNotExists <I18NConfig>(I18NConst.ConfigPath_Resources, AssetLoadType.Resources); refreshData(); } } else { if (mList_Regions == null) { mList_Regions = new ReorderableList(mConfig_SerObj, mConfig_SerObj.FindProperty("Regions"), true, //draggable true, //display head true, //add button true); //remove button mList_Regions.drawElementCallback = (rect, index, isActive, isFocused) => { rect.y += 2; rect.height = EditorGUIUtility.singleLineHeight; var singleLine = EditorGUIUtility.singleLineHeight + 2; float base_line = 0; SerializedProperty itemData = mList_Regions.serializedProperty.GetArrayElementAtIndex(index); SerializedProperty item_name = itemData.FindPropertyRelative("Name"); SerializedProperty item_bind_language = itemData.FindPropertyRelative("BindLanguage"); SerializedProperty item_json_dict = itemData.FindPropertyRelative("JsonDicts"); SerializedProperty item_asset_dict = itemData.FindPropertyRelative("AssetDicts"); //line 1 region name; var rect_regionName = rect; rect_regionName.width = 320; EditorGUI.PropertyField(rect_regionName, item_name, new GUIContent(I18Ns.RegionName)); base_line += 1; //line 2 Bind Language var rect_language_title = rect; rect_language_title.y += singleLine; rect_language_title.width = 125; EditorGUI.LabelField(rect_language_title, new GUIContent(I18Ns.BindLanaguage, I18Ns.BindLanaguage_Tip)); if (item_bind_language.arraySize > 0) { for (var i = 0; i < item_bind_language.arraySize; i++) { var _rect = rect; _rect.y += singleLine * (i + 1); _rect.x += 130; var _rect_content = _rect; _rect_content.width = 180; SerializedProperty item_language = item_bind_language.GetArrayElementAtIndex(i); EditorGUI.PropertyField(_rect_content, item_language, GUIContent.none); var _rect_del_btn = _rect; _rect_del_btn.width = 25; _rect_del_btn.x += _rect_content.width + 5; if (GUI.Button(_rect_del_btn, new GUIContent("×", "delete"))) { item_bind_language.DeleteArrayElementAtIndex(i); } } } var rect_language_add_btn = rect; rect_language_add_btn.y += singleLine * (item_bind_language.arraySize + 1); rect_language_add_btn.x += 130; rect_language_add_btn.width = 110; if (GUI.Button(rect_language_add_btn, "Add Language")) { int _index = item_bind_language.arraySize; item_bind_language.InsertArrayElementAtIndex(_index); var _item = item_bind_language.GetArrayElementAtIndex(_index); _item.enumValueIndex = 0; } base_line += item_bind_language.arraySize + 1.5f; //line 3 Json Dicts var rect_json_dict_title = rect; rect_json_dict_title.y += (base_line) * singleLine; rect_json_dict_title.width = 125; EditorGUI.LabelField(rect_json_dict_title, new GUIContent(I18Ns.JsonDict)); if (item_json_dict.arraySize > 0) { var _json_base_dict = rect; _json_base_dict.y += base_line * singleLine; for (var i = 0; i < item_json_dict.arraySize; i++) { var _rect = _json_base_dict; _rect.y += (singleLine * 3.5f) * i; _rect.x += 130; _rect.width -= 130; SerializedProperty _item_data = item_json_dict.GetArrayElementAtIndex(i); SerializedProperty _item_loadPath = _item_data.FindPropertyRelative("LoadPath"); SerializedProperty _item_editorloadPath = _item_data.FindPropertyRelative("EditorLoadPath"); SerializedProperty _item_groupname = _item_data.FindPropertyRelative("GroupName"); SerializedProperty _item_base64 = _item_data.FindPropertyRelative("Base64Value"); //line 1: load path var _rect_load_path = _rect; _rect_load_path.width -= 30; EditorGUI.PropertyField(_rect_load_path, _item_loadPath, new GUIContent(I18Ns.JsonLoadPath, I18Ns.JsonLoadPath_Tips)); //line 2: editor load path; var _rect_editor_load_path = _rect; _rect_editor_load_path.y += singleLine; _rect_editor_load_path.width -= 30; _rect_editor_load_path.width -= 55; EditorGUI.PropertyField(_rect_editor_load_path, _item_editorloadPath, new GUIContent(I18Ns.EditorJsonLoadPath, I18Ns.EditorJsonLoadPath_Tips)); var _rect_editor_load_path_btn = _rect; _rect_editor_load_path_btn.y += singleLine; _rect_editor_load_path_btn.width = 50; _rect_editor_load_path_btn.x += _rect_editor_load_path.width + 5; if (GUI.Button(_rect_editor_load_path_btn, "Select")) { var path = EditorUtility.OpenFilePanel("Select Lua Entry File", "Assets/", ""); if (!path.IsNullOrEmpty()) { var root_path = Directory.GetCurrentDirectory().Replace("\\", "/"); if (path.StartsWith(root_path)) { path = path.Substring(root_path.Length + 1, path.Length - root_path.Length - 1); path = path.Replace("\\", "/"); _item_editorloadPath.stringValue = path; } else { Debug.LogError("Invalid Path: " + path); } } } //line 3: group name and base 64 var _rect_groupName = _rect; _rect_groupName.y += singleLine * 2; _rect_groupName.width -= 30; _rect_groupName.width -= 125; EditorGUI.PropertyField(_rect_groupName, _item_groupname, new GUIContent("GroupName")); var _rect_base64 = _rect; _rect_base64.y += singleLine * 2; _rect_base64.x += _rect_groupName.width + 5; _rect_base64.width = 120; _item_base64.boolValue = EditorGUI.ToggleLeft(_rect_base64, new GUIContent("Value Is Base64", I18Ns.JsonB64_Tips), _item_base64.boolValue); //delete var _rect_del_btn = _rect; _rect_del_btn.width = 20; _rect_del_btn.x += _rect.width - 25; _rect_del_btn.height += singleLine * 2; if (GUI.Button(_rect_del_btn, new GUIContent("×", "Delete"))) { item_json_dict.DeleteArrayElementAtIndex(i); } } } var rect_json_add_btn = rect; rect_json_add_btn.y += (base_line * singleLine) + ((singleLine * 3.5f) * item_json_dict.arraySize); rect_json_add_btn.x += 130; rect_json_add_btn.width = 110; if (GUI.Button(rect_json_add_btn, "Add Json Dict")) { int _index = item_json_dict.arraySize; item_json_dict.InsertArrayElementAtIndex(_index); var _item = item_json_dict.GetArrayElementAtIndex(_index); var _item_loadPath = _item.FindPropertyRelative("LoadPath"); var _item_base64 = _item.FindPropertyRelative("Base64Value"); var _item_groupName = _item.FindPropertyRelative("GroupName"); var _item_editorLoadPath = _item.FindPropertyRelative("EditorLoadPath"); _item_loadPath.stringValue = string.Empty; _item_editorLoadPath.stringValue = string.Empty; _item_base64.boolValue = false; _item_groupName.stringValue = I18NConst.DefaultGroupName; } base_line += (item_json_dict.arraySize * 3.5f) + 1.5f; //line 4 Asset Dicts var rect_asset_dict_title = rect; rect_asset_dict_title.y += (base_line) * singleLine; rect_asset_dict_title.width = 125; EditorGUI.LabelField(rect_asset_dict_title, new GUIContent("Asset Dict")); if (item_asset_dict.arraySize > 0) { var _rect_base = rect; _rect_base.y += base_line * singleLine; for (var i = 0; i < item_asset_dict.arraySize; i++) { var _rect = _rect_base; _rect.x += 130; _rect.y += singleLine * i; _rect.width -= 130; SerializedProperty _item_data = item_asset_dict.GetArrayElementAtIndex(i); SerializedProperty _item_asset = _item_data.FindPropertyRelative("Asset"); SerializedProperty _item_groupName = _item_data.FindPropertyRelative("GroupName"); var _rect_groupName_title = _rect; _rect_groupName_title.width = 85; EditorGUI.LabelField(_rect_groupName_title, new GUIContent("GroupName")); var _rect_groupName = _rect; _rect_groupName.x += 90; _rect_groupName.width = 135; EditorGUI.PropertyField(_rect_groupName, _item_groupName, GUIContent.none); var _rect_asset = _rect; _rect_asset.x += 90 + 135 + 5; _rect_asset.width = 160; EditorGUI.PropertyField(_rect_asset, _item_asset, GUIContent.none); var _rect_btn_del = _rect; _rect_btn_del.x += 90 + 135 + 5 + 160 + 5; _rect_btn_del.width = 25; if (GUI.Button(_rect_btn_del, new GUIContent("×", "Delete"))) { item_asset_dict.DeleteArrayElementAtIndex(i); } } } var rect_asset_btn_add = rect; rect_asset_btn_add.y += (base_line + item_asset_dict.arraySize) * singleLine; rect_asset_btn_add.x += 130; rect_asset_btn_add.width = 110; if (GUI.Button(rect_asset_btn_add, "Add Asset Dict")) { int _index = item_asset_dict.arraySize; item_asset_dict.InsertArrayElementAtIndex(_index); var _item = item_asset_dict.GetArrayElementAtIndex(_index); var _item_asset = _item.FindPropertyRelative("Asset"); var _item_group = _item.FindPropertyRelative("GroupName"); _item_asset.objectReferenceValue = null; _item_group.stringValue = I18NConst.DefaultGroupName; } }; mList_Regions.elementHeightCallback = (index) => { SerializedProperty itemData = mList_Regions.serializedProperty.GetArrayElementAtIndex(index); SerializedProperty item_bind_language = itemData.FindPropertyRelative("BindLanguage"); SerializedProperty item_json_dict = itemData.FindPropertyRelative("JsonDicts"); SerializedProperty item_asset_dict = itemData.FindPropertyRelative("AssetDicts"); float line = 1; //绑定语言 line += item_bind_language.arraySize + 1.5f; //全局Json字典 line += (item_json_dict.arraySize * 3.5f) + 1.5f; //Asset字典 line += (item_asset_dict.arraySize) + 1; return (EditorGUIUtility.singleLineHeight + 2) * line + 2; }; mList_Regions.onAddCallback = (list) => { if (list.serializedProperty != null) { list.serializedProperty.arraySize++; list.index = list.serializedProperty.arraySize - 1; SerializedProperty itemData = list.serializedProperty.GetArrayElementAtIndex(list.index); SerializedProperty item_name = itemData.FindPropertyRelative("Name"); SerializedProperty item_bind_lan = itemData.FindPropertyRelative("BindLanguage"); SerializedProperty item_json = itemData.FindPropertyRelative("JsonDicts"); SerializedProperty item_asset = itemData.FindPropertyRelative("AssetDicts"); item_name.stringValue = string.Empty; item_bind_lan.ClearArray(); item_json.ClearArray(); item_asset.ClearArray(); } else { ReorderableList.defaultBehaviours.DoAddButton(list); } }; mList_Regions.drawHeaderCallback = (rect) => { EditorGUI.LabelField(rect, I18Ns.RegionList); }; } GUILayout.Space(10); EditorGUILayout.PropertyField(mConfig_SerObj.FindProperty("EnableI18N")); EditorGUILayout.PropertyField(mConfig_SerObj.FindProperty("DefaultRegion"), GUILayout.MaxWidth(300)); EditorGUILayout.PropertyField(mConfig_SerObj.FindProperty("AutomaticMatchingBySystemLanaguage"), new GUIContent("Auto Match", "Automatically match regions according to system language")); GUILayout.Space(10); mList_Regions.DoLayoutList(); if (mConfig_SerObj != null) { mConfig_SerObj.ApplyModifiedProperties(); } } EditorGUILayout.EndVertical(); }, deactivateHandler = () => { if (mConfig != null) { EditorUtility.SetDirty(mConfig); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } }, }); }