コード例 #1
0
    protected internal override void OnEnter(IFsm <IProcedureManager> procedureOwner)
    {
        base.OnEnter(procedureOwner);

        // 加载框架Event组件
        EventComponent   Event   = UnityGameFramework.Runtime.GameEntry.GetComponent <EventComponent>();
        SettingComponent Setting = UnityGameFramework.Runtime.GameEntry.GetComponent <SettingComponent>();

        // 加载框架Event组件
        localizationComponent = UnityGameFramework.Runtime.GameEntry.GetComponent <LocalizationComponent>();
        //// 订阅UI加载成功事件
        Event.Subscribe(LoadDictionarySuccessEventArgs.EventId, OnLoadDictionarySuccess);

        Language language = localizationComponent.Language;

        Log.Info(language);

        string languageString = Setting.GetString(Constant.Setting.Language);

        if (!string.IsNullOrEmpty(languageString))
        {
            try
            {
                language = (Language)Enum.Parse(typeof(Language), languageString);
            }
            catch
            {
            }
        }

        if (language != Language.English &&
            language != Language.ChineseSimplified &&
            language != Language.ChineseTraditional &&
            language != Language.Korean)
        {
            // 若是暂不支持的语言,则使用英语
            language = Language.English;

            Setting.SetString(Constant.Setting.Language, language.ToString());
            Setting.Save();
        }

        localizationComponent.Language = language;

        Log.Info(language);

        localizationComponent.LoadDictionary("Default", LoadType.Text, this);
    }
コード例 #2
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            SettingComponent t = (SettingComponent)target;

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            {
                m_SettingHelperInfo.Draw();
            }
            EditorGUI.EndDisabledGroup();

            if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject))
            {
                EditorGUILayout.LabelField("Setting Count", t.Count >= 0 ? t.Count.ToString() : "<Unknown>");
                if (t.Count > 0)
                {
                    string[] settingNames = t.GetAllSettingNames();
                    foreach (string settingName in settingNames)
                    {
                        EditorGUILayout.LabelField(settingName, t.GetString(settingName));
                    }
                }
            }

            if (EditorApplication.isPlaying)
            {
                if (GUILayout.Button("Save Settings"))
                {
                    t.Save();
                }
                if (GUILayout.Button("Remove All Settings"))
                {
                    t.RemoveAllSettings();
                }
            }

            serializedObject.ApplyModifiedProperties();

            Repaint();
        }