99 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			99 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using System.IO;
 | |
| using UnityEngine;
 | |
| 
 | |
| public class TKGParseGameConfig
 | |
| {
 | |
|     public static void Test()
 | |
|     {
 | |
|         TKGInnerParamsKey paramKey01 = new TKGInnerParamsKey();
 | |
|         paramKey01.key = "LevelList";
 | |
|         paramKey01.value = "1,78,72,70,64,65,4,66";
 | |
| 
 | |
|         TKGInnerParamsKey paramKey02 = new TKGInnerParamsKey();
 | |
|         paramKey02.key = "HasBlock";
 | |
|         paramKey02.value = "0";
 | |
| 
 | |
|         TKGInnerGameConfig config01 = new TKGInnerGameConfig();
 | |
|         config01.TKGParams.Add(paramKey01);
 | |
|         config01.TKGParams.Add(paramKey02);
 | |
| 
 | |
|         config01.TKGAdPositionName = new TKGInnerAdPositionName();
 | |
| 
 | |
|         config01.TKGAdPositionName.TKGIVAdPositionName.Add("IV_Success");
 | |
|         config01.TKGAdPositionName.TKGIVAdPositionName.Add("IV_Fail");
 | |
| 
 | |
|         config01.TKGAdPositionName.TKGRVPositionName.Add("RV_GetDoubleCoin");
 | |
|         config01.TKGAdPositionName.TKGRVPositionName.Add("RV_GetTips");
 | |
| 
 | |
|         
 | |
|         string ss = config01.SaveToString();
 | |
|         Debug.Log("ss : " + ss);
 | |
|     }
 | |
| }
 | |
| 
 | |
| #region Inner Class
 | |
| 
 | |
| [Serializable]
 | |
| public class TKGInnerParamsKey
 | |
| {
 | |
|     public string key;
 | |
|     public string value;
 | |
| 
 | |
| }
 | |
| 
 | |
| [Serializable]
 | |
| public class TKGInnerAdPositionName
 | |
| {
 | |
|     public List<string> TKGIVAdPositionName = new List<string>();
 | |
|     public List<string> TKGRVPositionName = new List<string>();
 | |
| }
 | |
| 
 | |
| 
 | |
| [Serializable]
 | |
| public class TKGInnerGameConfig
 | |
| {
 | |
|     public List<TKGInnerParamsKey> TKGParams = new List<TKGInnerParamsKey>();
 | |
|     public TKGInnerAdPositionName TKGAdPositionName;
 | |
| 
 | |
|     public string SaveToString()
 | |
|     {
 | |
|         return JsonUtility.ToJson(this);
 | |
|     }
 | |
| }
 | |
| 
 | |
| #endregion
 | |
| 
 | |
| #region load json
 | |
| 
 | |
| public class LoadJson
 | |
| {
 | |
|     public static T LoadJsonFromFile<T>(string _path) where T : class
 | |
|     {
 | |
|         if (!File.Exists(_path))
 | |
|         {
 | |
|             Debug.LogError("Don't Find " + _path);
 | |
|             return null;
 | |
|         }
 | |
| 
 | |
|         StreamReader sr = new StreamReader(_path);
 | |
|         if (sr == null)
 | |
|         {
 | |
|             return null;
 | |
|         }
 | |
|         string json = sr.ReadToEnd();
 | |
| 
 | |
|         if (json.Length > 0)
 | |
|         {
 | |
|             return JsonUtility.FromJson<T>(json);
 | |
|         }
 | |
|         return null;
 | |
|     }
 | |
| }
 | |
| 
 | |
| #endregion
 | |
| 
 | |
| 
 |