123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Newtonsoft.Json;
- using System.IO;
- using UnityEngine.Networking;
- using System;
- /* EnviromentController类主要功能是操作EnviromentSetting类,包含初始化数据,设置语言等 */
- public class EnviromentController : MonoBehaviour
- {
- // Start is called before the first frame update
- void Awake()
- {
- InitialGameEnviroment();
- }
- void Start()
- {
- // todo 开发代码,加载狗的信息,以后要移到ProgressBar页面
- DogProperty puppy_1 = new();
- UserProperty.dogs.Add(puppy_1);
- }
- public static void InitialGameEnviroment()
- {
- // 读取language.json
- string filePath = EnviromentSetting.langFilePath;
- string json = File.ReadAllText(filePath);
- EnviromentSetting.languageData = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
- // 读取系统语言
- string systemLanguage = Application.systemLanguage.ToString();
- if (systemLanguage == "ChineseSimplified")
- {
- EnviromentSetting.languageCode = "zh-cn";
- }
- // 默认语言为en
- // 读取操作系统,unique Id
- EnviromentSetting.platform = Application.platform.ToString();
- EnviromentSetting.UUID = SystemInfo.deviceUniqueIdentifier;
- // 读取Dogbreeds 数据
- DogBreedController.LoadDogBreed();
- }
- // Update is called once per frame
- //void Update()
- //{
- //}
- }
|