Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using System.Resources;
- using Assets.Scripts.Helpers;
- using UnityEngine;
- using SimpleJson;
- namespace Assets.Scripts
- {
- public sealed class LangSingleton
- {
- private readonly Dictionary<string, string> ourText = new Dictionary<string, string>();
- //создается объект нашего класса
- private static readonly LangSingleton instance = new LangSingleton();
- public static LangSingleton Instance
- {
- //тут типо возвращаем значение нашего объекта..
- get { return instance; }
- }
- //
- // защищённый конструктор нужен, чтобы предотвратить создание экземпляра класса Singleton
- protected LangSingleton() { }
- private void getText()
- {
- TextAsset asset = Resources.Load("ru") as TextAsset;
- if (asset != null)
- {
- ourText.Clear();
- var jsonText = JSON.Parse((asset.ToString()));
- for (int i = 0; i < jsonText.Count; i++)
- {
- ourText.Add(
- jsonText[i]["key"],
- jsonText[i]["value"]);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement