12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- namespace I2.Loc
- {
- public class LocalizationParamsManager : MonoBehaviour, ILocalizationParamsManager
- {
- public string GetParameterValue(string ParamName)
- {
- if (this._Params != null)
- {
- int i = 0;
- int count = this._Params.Count;
- while (i < count)
- {
- if (this._Params[i].Name == ParamName)
- {
- return this._Params[i].Value;
- }
- i++;
- }
- }
- return null;
- }
- public void SetParameterValue(string ParamName, string ParamValue, bool localize = true)
- {
- bool flag = false;
- int i = 0;
- int count = this._Params.Count;
- while (i < count)
- {
- if (this._Params[i].Name == ParamName)
- {
- LocalizationParamsManager.ParamValue value = this._Params[i];
- value.Value = ParamValue;
- this._Params[i] = value;
- flag = true;
- break;
- }
- i++;
- }
- if (!flag)
- {
- this._Params.Add(new LocalizationParamsManager.ParamValue
- {
- Name = ParamName,
- Value = ParamValue
- });
- }
- if (localize)
- {
- this.OnLocalize();
- }
- }
- public void OnLocalize()
- {
- Localize component = base.GetComponent<Localize>();
- if (component != null)
- {
- component.OnLocalize(true);
- }
- }
- public virtual void OnEnable()
- {
- this.DoAutoRegister();
- }
- public void DoAutoRegister()
- {
- if (!LocalizationManager.ParamManagers.Contains(this))
- {
- LocalizationManager.ParamManagers.Add(this);
- LocalizationManager.LocalizeAll(true);
- }
- }
- public void OnDisable()
- {
- LocalizationManager.ParamManagers.Remove(this);
- }
- [SerializeField]
- public List<LocalizationParamsManager.ParamValue> _Params = new List<LocalizationParamsManager.ParamValue>();
- [Serializable]
- public struct ParamValue
- {
- public string Name;
- public string Value;
- }
- }
- }
|