parent
							
								
									017d7177f4
								
							
						
					
					
						commit
						6beb8b7a76
					
				| 
						 | 
				
			
			@ -10,12 +10,12 @@ namespace Guru.Editor
 | 
			
		|||
    
 | 
			
		||||
    public class EditorGuruServiceIO
 | 
			
		||||
    {
 | 
			
		||||
        private static readonly string SourceConfigFileName = "guru-service";
 | 
			
		||||
        private const string LocalServicesConfigPath = "Guru/Resources";
 | 
			
		||||
        private const string SourceConfigExtension = ".json";
 | 
			
		||||
        private const string LocalConfigExtension = ".txt";
 | 
			
		||||
        internal static readonly string SourceConfigFileName = "guru-service";
 | 
			
		||||
        internal const string LocalServicesConfigPath = "Guru/Resources";
 | 
			
		||||
        internal const string SourceConfigExtension = ".json";
 | 
			
		||||
        internal const string LocalConfigExtension = ".txt";
 | 
			
		||||
 | 
			
		||||
        private static string DefaultFilePath =
 | 
			
		||||
        internal static string DefaultFilePath =
 | 
			
		||||
            Path.GetFullPath(Path.Combine(Application.dataPath, $"{SourceConfigFileName}{SourceConfigExtension}"));
 | 
			
		||||
 | 
			
		||||
        internal static string SourceServiceFilePath = "";
 | 
			
		||||
| 
						 | 
				
			
			@ -47,7 +47,7 @@ namespace Guru.Editor
 | 
			
		|||
        /// 保存配置
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="config"></param>
 | 
			
		||||
        internal static void SaveConfig(GuruServicesConfig config = null)
 | 
			
		||||
        internal static void SaveConfig(GuruServicesConfig config = null, string savePath = "")
 | 
			
		||||
        {
 | 
			
		||||
            if (config == null)
 | 
			
		||||
            {
 | 
			
		||||
| 
						 | 
				
			
			@ -59,12 +59,13 @@ namespace Guru.Editor
 | 
			
		|||
                PrettyPrint = true,
 | 
			
		||||
            };
 | 
			
		||||
            JsonMapper.ToJson(config, jw);
 | 
			
		||||
 | 
			
		||||
            var json = jw.ToString();
 | 
			
		||||
 | 
			
		||||
            if (string.IsNullOrEmpty(SourceServiceFilePath)) SourceServiceFilePath = DefaultFilePath;
 | 
			
		||||
            File.WriteAllText(SourceServiceFilePath, json);
 | 
			
		||||
            Debug.Log($"Save config to {SourceServiceFilePath}");
 | 
			
		||||
            if (string.IsNullOrEmpty(savePath)) savePath = SourceServiceFilePath;
 | 
			
		||||
            if (string.IsNullOrEmpty(savePath)) savePath = DefaultFilePath;
 | 
			
		||||
            
 | 
			
		||||
            File.WriteAllText(savePath, json);
 | 
			
		||||
            Debug.Log($"Save config to {savePath}");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,8 @@
 | 
			
		|||
namespace Guru.Editor
 | 
			
		||||
{
 | 
			
		||||
    using UnityEditor;
 | 
			
		||||
    using UnityEngine;
 | 
			
		||||
    
 | 
			
		||||
    public class GuruEditorHelper
 | 
			
		||||
    {
 | 
			
		||||
        public static string GetFilePath(string filter)
 | 
			
		||||
| 
						 | 
				
			
			@ -13,5 +15,17 @@ namespace Guru.Editor
 | 
			
		|||
            }
 | 
			
		||||
            return "";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void OpenPath(string path)
 | 
			
		||||
        {
 | 
			
		||||
#if UNITY_EDITOR_OSX
 | 
			
		||||
            EditorUtility.RevealInFinder(path);
 | 
			
		||||
            return;
 | 
			
		||||
#endif
 | 
			
		||||
            Application.OpenURL($"file://{path}");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,479 @@
 | 
			
		|||
 | 
			
		||||
namespace Guru.Editor
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.IO;
 | 
			
		||||
    using UnityEditor;
 | 
			
		||||
    using UnityEngine;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
    
 | 
			
		||||
    public class GuruServiceConverterHelper
 | 
			
		||||
    {
 | 
			
		||||
        const string k_app_settings = "app_settings";
 | 
			
		||||
        const string k_adjust_settings = "adjust_settings";
 | 
			
		||||
        const string k_fb_settings = "fb_settings";
 | 
			
		||||
        const string k_ad_settings = "ad_settings";
 | 
			
		||||
        const string k_iap_settings = "iap_settings";
 | 
			
		||||
        
 | 
			
		||||
        #region Export JSON
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 从 TSV 文件进行转化
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="tsvPath"></param>
 | 
			
		||||
        /// <param name="savePath"></param>
 | 
			
		||||
        public static void ConvertFromTSV(string tsvPath, string savePath = "")
 | 
			
		||||
        {
 | 
			
		||||
            if (!File.Exists(tsvPath))
 | 
			
		||||
            {
 | 
			
		||||
                EditorUtility.DisplayDialog("FILE NOT FOUND!", $"File not exist:\n{tsvPath}", "OK");
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            var guru_service = EditorGuruServiceIO.CreateEmpty();
 | 
			
		||||
                
 | 
			
		||||
            var lines = File.ReadAllLines(tsvPath);
 | 
			
		||||
            string line = "";
 | 
			
		||||
            for (int index = 0; index < lines.Length; index++)
 | 
			
		||||
            {
 | 
			
		||||
                line = lines[index];
 | 
			
		||||
                if (!IsInvalidLine(line))
 | 
			
		||||
                {
 | 
			
		||||
                    //---------------- app_settings ----------------
 | 
			
		||||
                    if (line.StartsWith(k_app_settings))
 | 
			
		||||
                    {
 | 
			
		||||
                        index++;
 | 
			
		||||
                        while (!line.StartsWith(k_adjust_settings))
 | 
			
		||||
                        {
 | 
			
		||||
                            line = lines[index];
 | 
			
		||||
                            FillAppSettings(guru_service, line);
 | 
			
		||||
                            index++;
 | 
			
		||||
                            line = lines[index];
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    //---------------- adjust_settings ----------------
 | 
			
		||||
                    if (line.StartsWith(k_adjust_settings))
 | 
			
		||||
                    {
 | 
			
		||||
                        index++;
 | 
			
		||||
                        FillAdjustSettings(guru_service, lines, ref index);
 | 
			
		||||
                    }
 | 
			
		||||
                    //---------------- fb_settings ----------------
 | 
			
		||||
                    if (line.StartsWith(k_fb_settings))
 | 
			
		||||
                    {
 | 
			
		||||
                        index++;
 | 
			
		||||
                        FillFacebookSettings(guru_service, lines, ref index);
 | 
			
		||||
                    }
 | 
			
		||||
                    //---------------- ad_settings ----------------
 | 
			
		||||
                    if (line.StartsWith(k_ad_settings))
 | 
			
		||||
                    {
 | 
			
		||||
                        index++;
 | 
			
		||||
                        FillAdSettings(guru_service, lines, ref index);
 | 
			
		||||
                    }
 | 
			
		||||
                    //---------------- iap_settings ----------------
 | 
			
		||||
                    if (line.StartsWith(k_iap_settings))
 | 
			
		||||
                    {
 | 
			
		||||
                        index++;
 | 
			
		||||
                        FillProducts(guru_service, lines, ref index);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            EditorGuruServiceIO.SourceServiceFilePath = savePath;
 | 
			
		||||
            EditorGuruServiceIO.SaveConfig(guru_service, savePath);
 | 
			
		||||
 | 
			
		||||
            if (EditorUtility.DisplayDialog("CONVERT SUCCESS!", $"Export Json to:\n{savePath}", "OK"))
 | 
			
		||||
            {
 | 
			
		||||
                GuruEditorHelper.OpenPath(Directory.GetParent(savePath)?.FullName ?? Application.dataPath);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// AppSettings 填充
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="settings"></param>
 | 
			
		||||
        /// <param name="line"></param>
 | 
			
		||||
        private static void FillAppSettings(GuruServicesConfig settings, string line)
 | 
			
		||||
        {
 | 
			
		||||
            // 对于空行和空值直接跳过
 | 
			
		||||
            if (IsInvalidLine(line)) return;
 | 
			
		||||
            
 | 
			
		||||
            string value = "";
 | 
			
		||||
            if(settings.app_settings == null) settings.app_settings = new GuruAppSettings();
 | 
			
		||||
            
 | 
			
		||||
            // 拾取值和注入
 | 
			
		||||
            if (GetValue(line, "app_id", out value))
 | 
			
		||||
            {
 | 
			
		||||
                settings.app_settings.app_id = value;
 | 
			
		||||
            }
 | 
			
		||||
            else if (GetValue(line, "product_name", out value))
 | 
			
		||||
            {
 | 
			
		||||
                settings.app_settings.product_name = value;
 | 
			
		||||
            }
 | 
			
		||||
            else if (GetValue(line, "bundle_id", out value))
 | 
			
		||||
            {
 | 
			
		||||
                settings.app_settings.bundle_id = value;
 | 
			
		||||
            }
 | 
			
		||||
            else if (GetValue(line, "support_email", out value))
 | 
			
		||||
            {
 | 
			
		||||
                settings.app_settings.support_email = value;
 | 
			
		||||
            }
 | 
			
		||||
            else if (GetValue(line, "privacy_url", out value))
 | 
			
		||||
            {
 | 
			
		||||
                settings.app_settings.privacy_url = value;
 | 
			
		||||
            }
 | 
			
		||||
            else if (GetValue(line, "terms_url", out value))
 | 
			
		||||
            {
 | 
			
		||||
                settings.app_settings.terms_url = value;
 | 
			
		||||
            }
 | 
			
		||||
            else if (GetValue(line, "android_store", out value))
 | 
			
		||||
            {
 | 
			
		||||
                settings.app_settings.android_store = value;
 | 
			
		||||
            }
 | 
			
		||||
            else if (GetValue(line, "ios_store", out value))
 | 
			
		||||
            {
 | 
			
		||||
                settings.app_settings.ios_store = value;
 | 
			
		||||
            }
 | 
			
		||||
            else if (GetValue(line, "level_end_success_num", out value))
 | 
			
		||||
            {
 | 
			
		||||
                settings.app_settings.level_end_success_num = GetInt(value);
 | 
			
		||||
            }
 | 
			
		||||
            else if (GetValue(line, "enable_keywords", out value))
 | 
			
		||||
            {
 | 
			
		||||
                settings.app_settings.enable_keywords = GetBool(value);
 | 
			
		||||
            }
 | 
			
		||||
            else if (GetValue(line, "enable_firebase", out value))
 | 
			
		||||
            {
 | 
			
		||||
                settings.app_settings.enable_firebase = GetBool(value);
 | 
			
		||||
            }
 | 
			
		||||
            else if (GetValue(line, "enable_facebook", out value))
 | 
			
		||||
            {
 | 
			
		||||
                settings.app_settings.enable_facebook = GetBool(value);
 | 
			
		||||
            }
 | 
			
		||||
            else if (GetValue(line, "enable_adjust", out value))
 | 
			
		||||
            {
 | 
			
		||||
                settings.app_settings.enable_adjust = GetBool(value);
 | 
			
		||||
            }
 | 
			
		||||
            else if (GetValue(line, "enable_iap", out value))
 | 
			
		||||
            {
 | 
			
		||||
                settings.app_settings.enable_iap = GetBool(value);
 | 
			
		||||
            }
 | 
			
		||||
            else if (GetValue(line, "tch_020", out value))
 | 
			
		||||
            {
 | 
			
		||||
                settings.app_settings.tch_020 = GetDouble(value);
 | 
			
		||||
            }
 | 
			
		||||
            else if (GetValue(line, "using_uuid", out value))
 | 
			
		||||
            {
 | 
			
		||||
                settings.app_settings.using_uuid = GetBool(value);
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// AdjustSettings 填充
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="settings"></param>
 | 
			
		||||
        /// <param name="line"></param>
 | 
			
		||||
        private static void FillAdjustSettings(GuruServicesConfig settings, string[] lines, ref int index)
 | 
			
		||||
        {
 | 
			
		||||
            if(settings.adjust_settings == null) settings.adjust_settings = new GuruAdjustSettings();
 | 
			
		||||
            string[] list = null;
 | 
			
		||||
            string line = lines[index];
 | 
			
		||||
            bool pass = false;
 | 
			
		||||
            List<string> events = new List<string>(20);
 | 
			
		||||
            
 | 
			
		||||
            while (!lines[index].StartsWith(k_fb_settings))
 | 
			
		||||
            {
 | 
			
		||||
                line = lines[index];
 | 
			
		||||
                if (!IsInvalidLine(line))
 | 
			
		||||
                {
 | 
			
		||||
                    if (line.StartsWith("app_token"))
 | 
			
		||||
                    {
 | 
			
		||||
                        list = GetStringArray(line, 1, 2);
 | 
			
		||||
                        settings.adjust_settings.app_token = list;
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        list = GetStringArray(line, 0, 3);
 | 
			
		||||
                        pass = list != null && !string.IsNullOrEmpty(list[0]) 
 | 
			
		||||
                                            && (!string.IsNullOrEmpty(list[1]) || !string.IsNullOrEmpty(list[2]));
 | 
			
		||||
                        if( pass) events.Add(string.Join(",", list));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                index++;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            settings.adjust_settings.events = events.ToArray();
 | 
			
		||||
            index--;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        private static void FillFacebookSettings(GuruServicesConfig settings, string[] lines, ref int index)
 | 
			
		||||
        {
 | 
			
		||||
            string value = "";
 | 
			
		||||
            if(settings.fb_settings == null) settings.fb_settings = new GuruFbSettings();
 | 
			
		||||
            var line = "";
 | 
			
		||||
 | 
			
		||||
            while (!lines[index].StartsWith(k_ad_settings))
 | 
			
		||||
            {
 | 
			
		||||
                line = lines[index];
 | 
			
		||||
                if (!IsInvalidLine(line))
 | 
			
		||||
                {
 | 
			
		||||
                    // 拾取值和注入
 | 
			
		||||
                    if (GetValue(line, "fb_app_id", out value))
 | 
			
		||||
                    {
 | 
			
		||||
                        settings.fb_settings.fb_app_id = value;
 | 
			
		||||
                    }
 | 
			
		||||
                    else if (GetValue(line, "fb_client_token", out value))
 | 
			
		||||
                    {
 | 
			
		||||
                        settings.fb_settings.fb_client_token = value;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                index++;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            index--;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        private static void FillAdSettings(GuruServicesConfig settings, string[] lines, ref int index)
 | 
			
		||||
        {
 | 
			
		||||
            string value = "";
 | 
			
		||||
            if(settings.ad_settings == null) settings.ad_settings = new GuruAdSettings();
 | 
			
		||||
            
 | 
			
		||||
            
 | 
			
		||||
            var line = lines[index];
 | 
			
		||||
            // SDK Key
 | 
			
		||||
           
 | 
			
		||||
 | 
			
		||||
            string[] max_ids_android = new string[3];
 | 
			
		||||
            string[] max_ids_ios = new string[3];
 | 
			
		||||
            string[] amazon_ids_android = new string[4];
 | 
			
		||||
            string[] amazon_ids_ios = new string[4];
 | 
			
		||||
            string[] pubmatic_ids_android = new string[3];
 | 
			
		||||
            string[] pubmatic_ids_ios = new string[3];
 | 
			
		||||
            string[] moloco_ids_android = new string[3];
 | 
			
		||||
            string[] moloco_ids_ios = new string[3];
 | 
			
		||||
            
 | 
			
		||||
            
 | 
			
		||||
            
 | 
			
		||||
            //------- 开始记录广告配置;
 | 
			
		||||
            string[] arr;
 | 
			
		||||
            while (!lines[index].StartsWith(k_iap_settings))
 | 
			
		||||
            {
 | 
			
		||||
                line = lines[index];
 | 
			
		||||
                
 | 
			
		||||
                if (GetValue(line, "sdk_key", out value))
 | 
			
		||||
                {
 | 
			
		||||
                    settings.ad_settings.sdk_key = value;
 | 
			
		||||
                }
 | 
			
		||||
                else if (line.StartsWith("admob_app_id"))
 | 
			
		||||
                {
 | 
			
		||||
                    settings.ad_settings.admob_app_id = GetStringArray(line, 1, 2);
 | 
			
		||||
                }
 | 
			
		||||
                else if (line.StartsWith("max_bads"))
 | 
			
		||||
                {
 | 
			
		||||
                    arr = GetStringArray(line, 1, 2);
 | 
			
		||||
                    max_ids_android[0] = arr[0];
 | 
			
		||||
                    max_ids_ios[0] = arr[1];
 | 
			
		||||
                }
 | 
			
		||||
                else if (line.StartsWith("max_iads"))
 | 
			
		||||
                {
 | 
			
		||||
                    arr = GetStringArray(line, 1, 2);
 | 
			
		||||
                    max_ids_android[1] = arr[0];
 | 
			
		||||
                    max_ids_ios[1] = arr[1];
 | 
			
		||||
                }
 | 
			
		||||
                else if (line.StartsWith("max_rads"))
 | 
			
		||||
                {
 | 
			
		||||
                    arr = GetStringArray(line, 1, 2);
 | 
			
		||||
                    max_ids_android[2] = arr[0];
 | 
			
		||||
                    max_ids_ios[2] = arr[1];
 | 
			
		||||
                }
 | 
			
		||||
                else if (line.StartsWith("amazon_app_id"))
 | 
			
		||||
                {
 | 
			
		||||
                    arr = GetStringArray(line, 1, 2);
 | 
			
		||||
                    amazon_ids_android[0] = arr[0];
 | 
			
		||||
                    amazon_ids_ios[0] = arr[1];
 | 
			
		||||
                }
 | 
			
		||||
                else if (line.StartsWith("amazon_bads"))
 | 
			
		||||
                {
 | 
			
		||||
                    arr = GetStringArray(line, 1, 2);
 | 
			
		||||
                    amazon_ids_android[1] = arr[0];
 | 
			
		||||
                    amazon_ids_ios[1] = arr[1];
 | 
			
		||||
                }
 | 
			
		||||
                else if (line.StartsWith("amazon_iads"))
 | 
			
		||||
                {
 | 
			
		||||
                    arr = GetStringArray(line, 1, 2);
 | 
			
		||||
                    amazon_ids_android[2] = arr[0];
 | 
			
		||||
                    amazon_ids_ios[2] = arr[1];
 | 
			
		||||
                }
 | 
			
		||||
                else if (line.StartsWith("amazon_rads"))
 | 
			
		||||
                {
 | 
			
		||||
                    arr = GetStringArray(line, 1, 2);
 | 
			
		||||
                    amazon_ids_android[3] = arr[0];
 | 
			
		||||
                    amazon_ids_ios[3] = arr[1];
 | 
			
		||||
                }
 | 
			
		||||
                else if (line.StartsWith("pubmatic_bads"))
 | 
			
		||||
                {
 | 
			
		||||
                    arr = GetStringArray(line, 1, 2);
 | 
			
		||||
                    pubmatic_ids_android[0] = arr[0];
 | 
			
		||||
                    pubmatic_ids_ios[0] = arr[1];
 | 
			
		||||
                }
 | 
			
		||||
                else if (line.StartsWith("pubmatic_iads"))
 | 
			
		||||
                {
 | 
			
		||||
                    arr = GetStringArray(line, 1, 2);
 | 
			
		||||
                    pubmatic_ids_android[1] = arr[0];
 | 
			
		||||
                    pubmatic_ids_ios[1] = arr[1];
 | 
			
		||||
                }
 | 
			
		||||
                else if (line.StartsWith("pubmatic_rads"))
 | 
			
		||||
                {
 | 
			
		||||
                    arr = GetStringArray(line, 1, 2);
 | 
			
		||||
                    pubmatic_ids_android[2] = arr[0];
 | 
			
		||||
                    pubmatic_ids_ios[2] = arr[1];
 | 
			
		||||
                }
 | 
			
		||||
                else if (line.StartsWith("moloco_bads"))
 | 
			
		||||
                {
 | 
			
		||||
                    arr = GetStringArray(line, 1, 2);
 | 
			
		||||
                    moloco_ids_android[0] = arr[0];
 | 
			
		||||
                    moloco_ids_ios[0] = arr[1];
 | 
			
		||||
                }
 | 
			
		||||
                else if (line.StartsWith("moloco_iads"))
 | 
			
		||||
                {
 | 
			
		||||
                    arr = GetStringArray(line, 1, 2);
 | 
			
		||||
                    moloco_ids_android[1] = arr[0];
 | 
			
		||||
                    moloco_ids_ios[1] = arr[1];
 | 
			
		||||
                }
 | 
			
		||||
                else if (line.StartsWith("moloco_rads"))
 | 
			
		||||
                {
 | 
			
		||||
                    arr = GetStringArray(line, 1, 2);
 | 
			
		||||
                    moloco_ids_android[2] = arr[0];
 | 
			
		||||
                    moloco_ids_ios[2] = arr[1];
 | 
			
		||||
                }
 | 
			
		||||
                index++;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            //-------- Fill all data -----------
 | 
			
		||||
            settings.ad_settings.max_ids_android = max_ids_android;
 | 
			
		||||
            settings.ad_settings.max_ids_ios = max_ids_ios;
 | 
			
		||||
            settings.ad_settings.amazon_ids_android = amazon_ids_android;
 | 
			
		||||
            settings.ad_settings.amazon_ids_ios = amazon_ids_ios;
 | 
			
		||||
            settings.ad_settings.pubmatic_ids_android = pubmatic_ids_android;
 | 
			
		||||
            settings.ad_settings.pubmatic_ids_ios = pubmatic_ids_ios;
 | 
			
		||||
            settings.ad_settings.moloco_ids_android = moloco_ids_android;
 | 
			
		||||
            settings.ad_settings.moloco_ids_ios = moloco_ids_ios;
 | 
			
		||||
            
 | 
			
		||||
            index--;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        private static void FillProducts(GuruServicesConfig settings, string[] lines, ref int index)
 | 
			
		||||
        {
 | 
			
		||||
            string line = "";
 | 
			
		||||
            List<string> iaps = new List<string>(30);
 | 
			
		||||
            
 | 
			
		||||
            string[] arr;
 | 
			
		||||
            while (index < lines.Length)
 | 
			
		||||
            {
 | 
			
		||||
                line = lines[index];
 | 
			
		||||
                if(IsInvalidLine(line)) continue;
 | 
			
		||||
                arr = GetStringArray(line, 0, 7);
 | 
			
		||||
                if(string.IsNullOrEmpty(arr[5])) arr[5] = "Store";
 | 
			
		||||
                if(string.IsNullOrEmpty(arr[6])) arr[6] = "0";
 | 
			
		||||
                iaps.Add(string.Join("," , arr));
 | 
			
		||||
                index++;
 | 
			
		||||
            }
 | 
			
		||||
            settings.products = iaps.ToArray();
 | 
			
		||||
            index--;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Utils
 | 
			
		||||
        
 | 
			
		||||
        private static bool GetBool(string value)
 | 
			
		||||
        {
 | 
			
		||||
            return value.ToLower() == "true" || value == "1";
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        private static int GetInt(string value)
 | 
			
		||||
        {
 | 
			
		||||
            int val = 0;
 | 
			
		||||
            int.TryParse(value, out val);
 | 
			
		||||
            return val;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        private static double GetDouble(string value)
 | 
			
		||||
        {
 | 
			
		||||
            double val = 0;
 | 
			
		||||
            double.TryParse(value, out val);
 | 
			
		||||
            return val;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private static bool IsInvalidLine(string line)
 | 
			
		||||
        {
 | 
			
		||||
            return (string.IsNullOrEmpty(line) || line.StartsWith("\t"));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private static bool GetValue(string line, string key, out string value)
 | 
			
		||||
        {
 | 
			
		||||
            value = ""; // default  
 | 
			
		||||
            if (line.StartsWith(key))
 | 
			
		||||
            {
 | 
			
		||||
                value = line.Split('\t')[1];
 | 
			
		||||
                if (string.IsNullOrEmpty(value)) value = "empty";
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private static string[] GetStringArray(string line, int startIndex = 0, int length = 0, string spliter = "\t")
 | 
			
		||||
        {
 | 
			
		||||
            if (IsInvalidLine(line)) return null;
 | 
			
		||||
            
 | 
			
		||||
            var raw = line.Split(spliter);
 | 
			
		||||
            if (length == 0) length = raw.Length;
 | 
			
		||||
            
 | 
			
		||||
            var a = new List<string>(length);
 | 
			
		||||
            for (int i = startIndex; i < length + startIndex; i++)
 | 
			
		||||
            {
 | 
			
		||||
                if (i < raw.Length)
 | 
			
		||||
                {
 | 
			
		||||
                    a.Add(raw[i]);
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    a.Add("");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return a.ToArray();
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
        
 | 
			
		||||
        #region Menu Items
 | 
			
		||||
 | 
			
		||||
#if GURU_SDK_DEV
 | 
			
		||||
        [MenuItem("Tools/Export Guru Service", false, 0 )]
 | 
			
		||||
#endif
 | 
			
		||||
        private static void ExportJsonFile()
 | 
			
		||||
        {
 | 
			
		||||
            string saveDir = Path.GetFullPath($"{Application.dataPath}/../output");
 | 
			
		||||
            string saveFile = Path.Combine(saveDir,$"guru-service____{DateTime.Now:yyyy-M-d-HH-mm}.json");
 | 
			
		||||
            
 | 
			
		||||
            if(!Directory.Exists(saveDir)) Directory.CreateDirectory(saveDir);
 | 
			
		||||
            
 | 
			
		||||
            string searchPath = "~/Downloads/";
 | 
			
		||||
            string tsv = EditorUtility.OpenFilePanel("Load Guru Service TSV", searchPath, ".tsv");
 | 
			
		||||
            if (!string.IsNullOrEmpty(tsv))
 | 
			
		||||
            {
 | 
			
		||||
                GuruServiceConverterHelper.ConvertFromTSV(tsv, saveFile);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,3 @@
 | 
			
		|||
fileFormatVersion: 2
 | 
			
		||||
guid: 8c7dc826ea0848f0a3bf05009fab6377
 | 
			
		||||
timeCreated: 1706856053
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +1,5 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using UnityEngine.Serialization;
 | 
			
		||||
 | 
			
		||||
namespace Guru
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -38,6 +37,7 @@ namespace Guru
 | 
			
		|||
                                                           && products != null && products.Length > 0;
 | 
			
		||||
        public bool IsKeywordsEnabled() => app_settings != null && app_settings.enable_keywords; 
 | 
			
		||||
        //-------------------------------- 配置检测 -------------------------------
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    [Serializable]    
 | 
			
		||||
| 
						 | 
				
			
			@ -58,7 +58,7 @@ namespace Guru
 | 
			
		|||
        public bool enable_facebook = true;
 | 
			
		||||
        public bool enable_adjust = true;
 | 
			
		||||
        public bool enable_iap = false;
 | 
			
		||||
        public double tch020_val = 0;
 | 
			
		||||
        public double tch_020 = 0;
 | 
			
		||||
        public bool using_uuid = false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
| 
						 | 
				
			
			@ -68,8 +68,8 @@ namespace Guru
 | 
			
		|||
        public string[] app_token;
 | 
			
		||||
        public string[] events;
 | 
			
		||||
 | 
			
		||||
        public string AndroidToken => app_token != null && app_token.Length > 0 ? app_token[0] : "";
 | 
			
		||||
        public string iOSToken => app_token != null && app_token.Length > 1 ? app_token[1] : "";
 | 
			
		||||
        public string AndroidToken() => app_token != null && app_token.Length > 0 ? app_token[0] : "";
 | 
			
		||||
        public string iOSToken() => app_token != null && app_token.Length > 1 ? app_token[1] : "";
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    [Serializable]
 | 
			
		||||
| 
						 | 
				
			
			@ -94,6 +94,4 @@ namespace Guru
 | 
			
		|||
        public string[] moloco_ids_ios;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -209,18 +209,19 @@ namespace Guru
 | 
			
		|||
                if (null != _appServicesConfig.adjust_settings && null != GuruSettings)
 | 
			
		||||
                {
 | 
			
		||||
                    // 更新 Adjust Tokens
 | 
			
		||||
                    GuruSettings.UpdateAdjustTokens(_appServicesConfig.adjust_settings.AndroidToken
 | 
			
		||||
                        , _appServicesConfig.adjust_settings.iOSToken);
 | 
			
		||||
                    GuruSettings.UpdateAdjustTokens(
 | 
			
		||||
                        _appServicesConfig.adjust_settings.AndroidToken(),
 | 
			
		||||
                        _appServicesConfig.adjust_settings.iOSToken());
 | 
			
		||||
                    // 更新 Adjust Events
 | 
			
		||||
                    GuruSettings.UpdateAdjustEvents(_appServicesConfig.adjust_settings.events);
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
                if (null != _appServicesConfig.app_settings)
 | 
			
		||||
                {
 | 
			
		||||
                    if (_appServicesConfig.app_settings.tch020_val > 0)
 | 
			
		||||
                    if (_appServicesConfig.app_settings.tch_020 > 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        Analytics.EnableTch02Event = true;
 | 
			
		||||
                        Analytics.SetTch02TargetValue(_appServicesConfig.app_settings.tch020_val);
 | 
			
		||||
                        Analytics.SetTch02TargetValue(_appServicesConfig.app_settings.tch_020);
 | 
			
		||||
                    }
 | 
			
		||||
                     
 | 
			
		||||
                    // 设置获取设备 UUID 的方法
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue