1006 lines
		
	
	
		
			40 KiB
		
	
	
	
		
			C#
		
	
	
			
		
		
	
	
			1006 lines
		
	
	
		
			40 KiB
		
	
	
	
		
			C#
		
	
	
namespace Guru.Editor
 | 
						|
{
 | 
						|
    using System;
 | 
						|
    using UnityEditor;
 | 
						|
    using UnityEngine;
 | 
						|
    using Guru;
 | 
						|
    using System.Collections.Generic;
 | 
						|
    using System.IO;
 | 
						|
    using Facebook.Unity.Settings;
 | 
						|
    using UnityEditor.Compilation;
 | 
						|
    
 | 
						|
    public class GuruSDKManager: EditorWindow
 | 
						|
    {
 | 
						|
        private const string GURU_SETTINGS_PATH = "Assets/Guru/Resources/GuruSettings.asset";
 | 
						|
        private const string APPLOVIN_SETTINGS_PATH = "Assets/Guru/Resources/AppLovinSettings.asset";
 | 
						|
        private const string FACEBOOK_SETTINGS_PATH = "Assets/FacebookSDK/SDK/Resources/FacebookSettings.asset";
 | 
						|
        private const string ANDROID_KEYSTORE_PATH = "Assets/Plugins/Android/guru_key.jks";
 | 
						|
        private const string KeyMaxAutoUpdateEnabled = "com.applovin.auto_update_enabled";
 | 
						|
        
 | 
						|
        
 | 
						|
        private static GuruSDKManager _instance;
 | 
						|
        public static GuruSDKManager Instance {
 | 
						|
            get
 | 
						|
            {
 | 
						|
                if (_instance == null)
 | 
						|
                {
 | 
						|
                    _instance = GetWindow<GuruSDKManager>();
 | 
						|
                }
 | 
						|
                return _instance;
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        private GuruServicesConfig _servicesConfig;
 | 
						|
        private static GUIStyle _itemTitleStyle;
 | 
						|
        private static GUIStyle StyleItemTitle
 | 
						|
        {
 | 
						|
            get
 | 
						|
            {
 | 
						|
                if (_itemTitleStyle == null)
 | 
						|
                {
 | 
						|
                    _itemTitleStyle = new GUIStyle("BOX")
 | 
						|
                    {
 | 
						|
                        fontSize = 12,
 | 
						|
                        fontStyle = FontStyle.Bold,
 | 
						|
                        stretchWidth = true,
 | 
						|
                        alignment = TextAnchor.MiddleLeft,
 | 
						|
                        padding = new RectOffset(4, 4, 4, 4),
 | 
						|
                    };
 | 
						|
                }
 | 
						|
                return _itemTitleStyle;
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        private bool _hasCheckingCompleted = false;
 | 
						|
 | 
						|
 | 
						|
        public GuruSDKManager()
 | 
						|
        {
 | 
						|
            this.minSize = new Vector2(480, 640);
 | 
						|
        }
 | 
						|
        
 | 
						|
 | 
						|
        public static void Open()
 | 
						|
        {
 | 
						|
            Instance.Show();
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        private void OnEnable()
 | 
						|
        {
 | 
						|
            titleContent = new GUIContent("Guru SDK Manager");
 | 
						|
            _servicesConfig = EditorGuruServiceIO.LoadConfig();
 | 
						|
            if (_servicesConfig != null)
 | 
						|
            {
 | 
						|
                Debug.Log($"<color=#88ff00>[Guru] Load <guru-services> success.</color>");
 | 
						|
                CheckServicesCompletion();
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                Debug.Log($"<color=red>[Guru] <guru-services> file not found...</color>");
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        #region Service Checker
 | 
						|
 | 
						|
        enum CheckStatus
 | 
						|
        {
 | 
						|
            Passed,
 | 
						|
            Warning,
 | 
						|
            Failed,
 | 
						|
        }
 | 
						|
 | 
						|
        private const string MARK_FAIL = "#FAIL";
 | 
						|
        private const string MARK_WARN = "#WARN";
 | 
						|
        private const string MARK_INDENT = "    ";
 | 
						|
        private List<string> _completionCheckResult;
 | 
						|
        private int _serviceCriticalFail = 0;
 | 
						|
        private int _serviceNormalFail = 0;
 | 
						|
        
 | 
						|
        /// <summary>
 | 
						|
        /// 检查服务文件的配置完整性
 | 
						|
        /// </summary>
 | 
						|
        private void CheckServicesCompletion()
 | 
						|
        {
 | 
						|
            _serviceCriticalFail = 0;
 | 
						|
            _serviceNormalFail = 0;
 | 
						|
            
 | 
						|
            _completionCheckResult = new List<string>(40);
 | 
						|
            string mk_yes = " ( \u2714 ) ";
 | 
						|
            string mk_no = " ( \u2718 ) ";
 | 
						|
            string mk_warn = " ( ! ) ";
 | 
						|
            string mk_star = " ( \u2605 ) ";
 | 
						|
            string check_passed = $"{MARK_INDENT}{mk_yes} All items passed!";
 | 
						|
            if (_servicesConfig == null)
 | 
						|
            {
 | 
						|
                AddResultLine($"{mk_yes} guru-services is missing", CheckStatus.Failed);
 | 
						|
                AddResultLine($"Please contact Guru tech support to get help.", CheckStatus.Failed);
 | 
						|
                _serviceCriticalFail++;
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                bool passed = true;
 | 
						|
                AddResultLine($"{mk_star} <guru-services> exists!");
 | 
						|
                if (_servicesConfig.app_settings != null 
 | 
						|
                    && !string.IsNullOrEmpty(_servicesConfig.app_settings.bundle_id))
 | 
						|
                {
 | 
						|
                    AddResultLine($"{MARK_INDENT}  +  {MARK_INDENT}{_servicesConfig.app_settings.bundle_id}");
 | 
						|
                }
 | 
						|
 | 
						|
                AddResultLine($"--------------------------------");
 | 
						|
                
 | 
						|
                //-------- APP Settings --------
 | 
						|
                passed = true;
 | 
						|
                AddResultLine($"[ App ]");
 | 
						|
                if (_servicesConfig.app_settings == null)
 | 
						|
                {
 | 
						|
                    passed = false;
 | 
						|
                    AddResultLine($"{MARK_INDENT}{mk_no} settings is missing!", CheckStatus.Failed);
 | 
						|
                    _serviceCriticalFail++;
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    if (_servicesConfig.app_settings.app_id.IsNullOrEmpty())
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_no} AppID is missing!", CheckStatus.Failed);
 | 
						|
                        _serviceCriticalFail++;
 | 
						|
                    }
 | 
						|
                    if (_servicesConfig.app_settings.bundle_id.IsNullOrEmpty())
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_no} BundleID is missing!", CheckStatus.Failed);
 | 
						|
                        _serviceCriticalFail++;
 | 
						|
                    }
 | 
						|
                    if (_servicesConfig.app_settings.product_name.IsNullOrEmpty())
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_no} Product Name is missing!", CheckStatus.Failed);
 | 
						|
                        _serviceCriticalFail++;
 | 
						|
                    }
 | 
						|
                    if (_servicesConfig.app_settings.support_email.IsNullOrEmpty())
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_no} Support Email is missing!", CheckStatus.Failed);
 | 
						|
                        _serviceNormalFail++;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                
 | 
						|
                if (passed) AddResultLine(check_passed);
 | 
						|
                
 | 
						|
                //-------- ADS Settings --------
 | 
						|
                passed = true;
 | 
						|
                AddResultLine($"[ Ads ]");
 | 
						|
                if (_servicesConfig.ad_settings == null)
 | 
						|
                {
 | 
						|
                    passed = false;
 | 
						|
                    AddResultLine($"{MARK_INDENT}{mk_no} settings is missing!", CheckStatus.Failed);
 | 
						|
                    _serviceCriticalFail++;
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    if (_servicesConfig.ad_settings.sdk_key.IsNullOrEmpty())
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_no} SDK Key is missing!", CheckStatus.Failed);
 | 
						|
                        _serviceCriticalFail++;
 | 
						|
                    }
 | 
						|
                    if (!IsArrayNotEmpty(_servicesConfig.ad_settings.admob_app_id))
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_no} Admob ID is missing!", CheckStatus.Failed);
 | 
						|
                        _serviceCriticalFail++;
 | 
						|
                    }
 | 
						|
                    if (!IsArrayNotEmpty(_servicesConfig.ad_settings.max_ids_android))
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_no} AppLovin Android IDs is missing!", CheckStatus.Failed);
 | 
						|
                        _serviceCriticalFail++;
 | 
						|
                    }
 | 
						|
                    if (!IsArrayNotEmpty(_servicesConfig.ad_settings.max_ids_ios))
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_no} AppLovin iOS IDs is missing!", CheckStatus.Failed);
 | 
						|
                        _serviceCriticalFail++;
 | 
						|
                    }
 | 
						|
                    if (!IsArrayNotEmpty(_servicesConfig.ad_settings.amazon_ids_android))
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_warn} Amazon Android IDs is missing!", CheckStatus.Warning);
 | 
						|
                        _serviceNormalFail++;
 | 
						|
                    }
 | 
						|
                    if (!IsArrayNotEmpty(_servicesConfig.ad_settings.amazon_ids_ios))
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_warn} Amazon iOS IDs is missing!", CheckStatus.Warning);
 | 
						|
                        _serviceNormalFail++;
 | 
						|
                    }
 | 
						|
                    if (!IsArrayNotEmpty(_servicesConfig.ad_settings.pubmatic_ids_android))
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_warn} Pubmatic Android IDs is missing!", CheckStatus.Warning);
 | 
						|
                        _serviceNormalFail++;
 | 
						|
                    }
 | 
						|
                    if (!IsArrayNotEmpty(_servicesConfig.ad_settings.pubmatic_ids_ios))
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_warn} Pubmatic iOS IDs is missing!", CheckStatus.Warning);
 | 
						|
                        _serviceNormalFail++;
 | 
						|
                    }
 | 
						|
                    if (!IsArrayNotEmpty(_servicesConfig.ad_settings.moloco_ids_android))
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_warn} Moloco Android Test IDs is missing!", CheckStatus.Warning);
 | 
						|
                        _serviceNormalFail++;
 | 
						|
                    }
 | 
						|
                    if (!IsArrayNotEmpty(_servicesConfig.ad_settings.moloco_ids_ios))
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_warn} Moloco iOS Test IDs is missing!", CheckStatus.Warning);
 | 
						|
                        _serviceNormalFail++;
 | 
						|
                    }
 | 
						|
                    if (!IsArrayNotEmpty(_servicesConfig.ad_settings.tradplus_ids_android))
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_warn} Tradplus Android Test IDs is missing!", CheckStatus.Warning);
 | 
						|
                        _serviceNormalFail++;
 | 
						|
                    }
 | 
						|
                    if (!IsArrayNotEmpty(_servicesConfig.ad_settings.tradplus_ids_ios))
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_warn} Tradplus iOS Test IDs is missing!", CheckStatus.Warning);
 | 
						|
                        _serviceNormalFail++;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                if (passed) AddResultLine(check_passed);
 | 
						|
                
 | 
						|
                //-------- Channels Settings --------
 | 
						|
                passed = true;
 | 
						|
                AddResultLine($"[ Channels ]");
 | 
						|
                if (_servicesConfig.fb_settings == null)
 | 
						|
                {
 | 
						|
                    passed = false;
 | 
						|
                    AddResultLine($"{MARK_INDENT}{mk_warn} Facebook settings is missing!", CheckStatus.Warning);
 | 
						|
                    _serviceNormalFail++;
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    if (_servicesConfig.fb_settings.fb_app_id.IsNullOrEmpty())
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_warn} Facebook AppID is missing!", CheckStatus.Warning);
 | 
						|
                        _serviceNormalFail++;
 | 
						|
                    }
 | 
						|
                    if (_servicesConfig.fb_settings.fb_client_token.IsNullOrEmpty())
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_warn} Facebook Client Token is missing!", CheckStatus.Warning);
 | 
						|
                        _serviceNormalFail++;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
 | 
						|
                if (_servicesConfig.adjust_settings == null)
 | 
						|
                {
 | 
						|
                    passed = false;
 | 
						|
                    AddResultLine($"{MARK_INDENT}{mk_warn} Adjust settings is missing!", CheckStatus.Warning);
 | 
						|
                    _serviceNormalFail++;
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    if(!IsArrayNotEmpty(_servicesConfig.adjust_settings.app_token))
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_warn} Adjust AppToken is missing!", CheckStatus.Warning);
 | 
						|
                        _serviceNormalFail++;
 | 
						|
                    }
 | 
						|
 | 
						|
                    if (!IsArrayNotEmpty(_servicesConfig.adjust_settings.events))
 | 
						|
                    {
 | 
						|
                        passed = false;
 | 
						|
                        AddResultLine($"{MARK_INDENT}{mk_warn} Adjust Events is missing!", CheckStatus.Warning);
 | 
						|
                        _serviceNormalFail++;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                if (passed) AddResultLine(check_passed);
 | 
						|
                
 | 
						|
                //-------- IAP --------
 | 
						|
                passed = true;
 | 
						|
                AddResultLine($"[ IAP ]");
 | 
						|
                if (!IsArrayNotEmpty(_servicesConfig.products))
 | 
						|
                {
 | 
						|
                    passed = false;
 | 
						|
                    AddResultLine($"{MARK_INDENT}{mk_warn} Product list is missing!", CheckStatus.Warning);
 | 
						|
                    _serviceNormalFail++;
 | 
						|
                }
 | 
						|
                if (passed) AddResultLine(check_passed);
 | 
						|
            }
 | 
						|
 | 
						|
        }
 | 
						|
 | 
						|
        private void AddResultLine(string msg, CheckStatus status = CheckStatus.Passed)
 | 
						|
        {
 | 
						|
            if (_completionCheckResult == null)
 | 
						|
            {
 | 
						|
                _completionCheckResult = new List<string>(40);
 | 
						|
            }
 | 
						|
 | 
						|
            string mk = "";
 | 
						|
            switch (status)
 | 
						|
            {
 | 
						|
                case CheckStatus.Passed:
 | 
						|
                    mk = ""; 
 | 
						|
                    break;
 | 
						|
                case CheckStatus.Warning:
 | 
						|
                    mk = MARK_WARN;
 | 
						|
                    break;
 | 
						|
                case CheckStatus.Failed:
 | 
						|
                    mk = MARK_FAIL;
 | 
						|
                    break;
 | 
						|
            }
 | 
						|
            _completionCheckResult.Add($"{msg}{mk}");
 | 
						|
        }
 | 
						|
 | 
						|
        private void GUI_ServiceCheckResult()
 | 
						|
        {
 | 
						|
            if (_completionCheckResult != null)
 | 
						|
            {
 | 
						|
                Color green = new Color(0.7f, 1, 0);
 | 
						|
                Color red = new Color(1, 0.2f, 0);
 | 
						|
                Color yellow = new Color(1f, 0.8f, 0.2f);
 | 
						|
                Color c;
 | 
						|
                string line = "";
 | 
						|
                for (int i = 0; i < _completionCheckResult.Count; i++)
 | 
						|
                {
 | 
						|
                    c = green;
 | 
						|
                    line = _completionCheckResult[i];
 | 
						|
                    if (line.EndsWith(MARK_FAIL))
 | 
						|
                    {
 | 
						|
                        line = line.Replace(MARK_FAIL, "");
 | 
						|
                        c = red;
 | 
						|
                    }
 | 
						|
                    else if (line.EndsWith(MARK_WARN))
 | 
						|
                    {
 | 
						|
                        line = line.Replace(MARK_WARN, "");
 | 
						|
                        c = yellow;
 | 
						|
                    }
 | 
						|
                    GUI_Color(c, () =>
 | 
						|
                    {
 | 
						|
                        EditorGUILayout.LabelField(line);
 | 
						|
                        GUILayout.Space(2);
 | 
						|
                    });
 | 
						|
                    
 | 
						|
                }
 | 
						|
            }
 | 
						|
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        #endregion
 | 
						|
        
 | 
						|
        #region GUI
 | 
						|
 | 
						|
        void OnGUI()
 | 
						|
        {
 | 
						|
            // TITLE
 | 
						|
            GUI_WindowTitle();
 | 
						|
            
 | 
						|
            // CONTENT
 | 
						|
            if (_servicesConfig == null)
 | 
						|
            {
 | 
						|
                GUI_OnConfigDisabled();
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                GUI_OnConfigEnabled();
 | 
						|
            }
 | 
						|
 | 
						|
        }
 | 
						|
 | 
						|
        private void GUI_WindowTitle()
 | 
						|
        {
 | 
						|
            GUILayout.Space(4);
 | 
						|
            
 | 
						|
            var s = new GUIStyle("BOX")
 | 
						|
            {
 | 
						|
                fontSize = 36,
 | 
						|
                fontStyle = FontStyle.Bold,
 | 
						|
                alignment = TextAnchor.MiddleCenter,
 | 
						|
                stretchWidth = true,
 | 
						|
                stretchHeight = true,
 | 
						|
                fixedHeight = 60,
 | 
						|
            };
 | 
						|
 | 
						|
 | 
						|
            EditorGUILayout.LabelField("Guru SDK",s);
 | 
						|
            s.fontSize = 13;
 | 
						|
            s.fixedHeight = 20;
 | 
						|
            EditorGUILayout.LabelField($"Version {GuruSDK.Version}", s);
 | 
						|
            
 | 
						|
            GUILayout.Space(4);
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 配置不可用
 | 
						|
        /// </summary>
 | 
						|
        private void GUI_OnConfigDisabled()
 | 
						|
        {
 | 
						|
            GUI_Color(new Color(1,0.2f, 0), () =>
 | 
						|
            {
 | 
						|
                EditorGUILayout.LabelField("<guru-services> file not found! \nPlease contact Guru tech support to solve the problem. ", StyleItemTitle);
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 配置可用
 | 
						|
        /// </summary>
 | 
						|
        private void GUI_OnConfigEnabled()
 | 
						|
        {
 | 
						|
            var box = new GUIStyle("BOX");
 | 
						|
            float btnH = 40;
 | 
						|
            
 | 
						|
            //------------ check allsettings -------------
 | 
						|
            EditorGUILayout.LabelField("[ Guru Service ]", StyleItemTitle);
 | 
						|
            GUILayout.Space(2);
 | 
						|
            GUI_ServiceCheckResult();
 | 
						|
            GUILayout.Space(16);
 | 
						|
 | 
						|
            if (_serviceCriticalFail > 0)
 | 
						|
            {
 | 
						|
                // 严重错误过多
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                GUI_Button("IMPORT ALL SETTINGS", () =>
 | 
						|
                {
 | 
						|
                    CheckAllComponents();
 | 
						|
                }, null, GUILayout.Height(btnH));
 | 
						|
            }
 | 
						|
            
 | 
						|
            GUILayout.Space(4);
 | 
						|
         
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        #endregion
 | 
						|
        
 | 
						|
        #region Check Components
 | 
						|
 | 
						|
        private string logBuffer;
 | 
						|
        
 | 
						|
        
 | 
						|
        private void CheckAllComponents()
 | 
						|
        {
 | 
						|
            float progress = 0;
 | 
						|
            string barTitle = "Setup All Components";
 | 
						|
            EditorUtility.DisplayCancelableProgressBar(barTitle, "Start collect all components", progress);
 | 
						|
            Debug.Log("--- Setup All Components ---");
 | 
						|
            ApplyMods();
 | 
						|
            progress += 0.2f;
 | 
						|
            EditorUtility.DisplayCancelableProgressBar(barTitle, "Setup Mods is done", progress);  
 | 
						|
            ImportGuruSettings();
 | 
						|
            progress += 0.2f;
 | 
						|
            EditorUtility.DisplayCancelableProgressBar(barTitle, "GuruSettings is done", progress);
 | 
						|
            ImportAppLovinSettings();
 | 
						|
            progress += 0.2f;
 | 
						|
            EditorUtility.DisplayCancelableProgressBar(barTitle, "AppLovinSettings is done", progress);
 | 
						|
            ImportFacebookSettings();
 | 
						|
            progress += 0.2f;
 | 
						|
            EditorUtility.DisplayCancelableProgressBar(barTitle, "FacebookSettings is done", progress);
 | 
						|
            
 | 
						|
            
 | 
						|
            EditorGuruServiceIO.DeployLocalServiceFile(); // 部署文件
 | 
						|
            
 | 
						|
            AssetDatabase.SaveAssets();
 | 
						|
            
 | 
						|
            CompilationPipeline.RequestScriptCompilation();
 | 
						|
            CompilationPipeline.compilationFinished += o =>
 | 
						|
            {
 | 
						|
                EditorUtility.ClearProgressBar();
 | 
						|
                AssetDatabase.Refresh();
 | 
						|
 | 
						|
                EditorUtility.DisplayDialog("Importing Guru Services", "All the settings importing success!", "OK");
 | 
						|
            };
 | 
						|
        }
 | 
						|
 | 
						|
        //------------------------- GuruSettings --------------------------------
 | 
						|
        private void ImportGuruSettings()
 | 
						|
        {
 | 
						|
            GuruSettings settings = null;
 | 
						|
            if (IsAssetExists(nameof(GuruSettings), GURU_SETTINGS_PATH))
 | 
						|
            {
 | 
						|
                settings = AssetDatabase.LoadAssetAtPath<GuruSettings>(GURU_SETTINGS_PATH);
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                EnsureParentDirectory(GURU_SETTINGS_PATH);
 | 
						|
                settings = CreateInstance<GuruSettings>();
 | 
						|
                AssetDatabase.CreateAsset(settings, GURU_SETTINGS_PATH);
 | 
						|
            }
 | 
						|
            settings.CompanyName = "Guru";
 | 
						|
            settings.ProductName = _servicesConfig.app_settings.product_name;
 | 
						|
            settings.GameIdentifier = _servicesConfig.app_settings.bundle_id;
 | 
						|
            settings.PriacyUrl = _servicesConfig.app_settings.privacy_url;
 | 
						|
            settings.TermsUrl = _servicesConfig.app_settings.terms_url;
 | 
						|
            settings.SupportEmail = _servicesConfig.app_settings.support_email;
 | 
						|
            settings.AndroidStoreUrl = _servicesConfig.app_settings.android_store;
 | 
						|
            settings.IOSStoreUrl = _servicesConfig.app_settings.ios_store;
 | 
						|
            
 | 
						|
            SerializedObject so = new SerializedObject(settings);
 | 
						|
            SerializedProperty n;
 | 
						|
            SerializedObject nn;
 | 
						|
            SerializedProperty p;
 | 
						|
            string[] arr;
 | 
						|
            
 | 
						|
            n = so.FindProperty("IPMSetting");
 | 
						|
            if (null != n)
 | 
						|
            {
 | 
						|
                // AppID
 | 
						|
                p = n.serializedObject.FindProperty("IPMSetting.appID");
 | 
						|
                p.stringValue = _servicesConfig.app_settings.app_id;
 | 
						|
                // BundleID
 | 
						|
                p = n.serializedObject.FindProperty("IPMSetting.bundleId");
 | 
						|
                p.stringValue = _servicesConfig.app_settings.bundle_id;
 | 
						|
                // tokenValidTime
 | 
						|
                if (_servicesConfig.TokenValidTime() > 0)
 | 
						|
                {
 | 
						|
                    p = n.serializedObject.FindProperty("IPMSetting.tokenValidTime");
 | 
						|
                    p.intValue = _servicesConfig.TokenValidTime();
 | 
						|
                }
 | 
						|
                if (_servicesConfig.fb_settings != null)
 | 
						|
                {
 | 
						|
                    // FB App ID
 | 
						|
                    p = n.serializedObject.FindProperty("IPMSetting.fbAppId");
 | 
						|
                    p.stringValue = _servicesConfig.fb_settings.fb_app_id;
 | 
						|
                    // FB Client Token
 | 
						|
                    p = n.serializedObject.FindProperty("IPMSetting.fbClientToken");
 | 
						|
                    p.stringValue = _servicesConfig.fb_settings.fb_client_token;
 | 
						|
                }
 | 
						|
            }
 | 
						|
 | 
						|
            //---------- AMAZON -----------------------
 | 
						|
            n = so.FindProperty("AmazonSetting");
 | 
						|
            if (null != n)
 | 
						|
            {
 | 
						|
                p = n.serializedObject.FindProperty("AmazonSetting.Enable");
 | 
						|
                p.boolValue = true;
 | 
						|
                
 | 
						|
                arr = _servicesConfig.ad_settings.amazon_ids_android;
 | 
						|
                if (IsArrayHasLength(arr, 4))
 | 
						|
                {
 | 
						|
                    p = n.serializedObject.FindProperty("AmazonSetting.Android.appID");
 | 
						|
                    p.stringValue = arr[0];
 | 
						|
                    p = n.serializedObject.FindProperty("AmazonSetting.Android.bannerSlotID");
 | 
						|
                    p.stringValue = arr[1];
 | 
						|
                    p = n.serializedObject.FindProperty("AmazonSetting.Android.interSlotID");
 | 
						|
                    p.stringValue = arr[2];
 | 
						|
                    p = n.serializedObject.FindProperty("AmazonSetting.Android.rewardSlotID");
 | 
						|
                    p.stringValue = arr[3];
 | 
						|
                }
 | 
						|
 | 
						|
                arr = _servicesConfig.ad_settings.amazon_ids_ios;
 | 
						|
                if (IsArrayHasLength(arr, 4))
 | 
						|
                {
 | 
						|
                    p = n.serializedObject.FindProperty("AmazonSetting.iOS.appID");
 | 
						|
                    p.stringValue = arr[0];
 | 
						|
                    p = n.serializedObject.FindProperty("AmazonSetting.iOS.bannerSlotID");
 | 
						|
                    p.stringValue = arr[1];
 | 
						|
                    p = n.serializedObject.FindProperty("AmazonSetting.iOS.interSlotID");
 | 
						|
                    p.stringValue = arr[2];
 | 
						|
                    p = n.serializedObject.FindProperty("AmazonSetting.iOS.rewardSlotID");
 | 
						|
                    p.stringValue = arr[3];
 | 
						|
                }
 | 
						|
            }
 | 
						|
            
 | 
						|
            //---------- PUBMATIC -----------------------
 | 
						|
            n = so.FindProperty("PubmaticSetting");
 | 
						|
            if (null != n)
 | 
						|
            {
 | 
						|
                p = n.serializedObject.FindProperty("PubmaticSetting.Enable");
 | 
						|
                p.boolValue = true;
 | 
						|
 | 
						|
                p = n.serializedObject.FindProperty("PubmaticSetting.Android.storeUrl");
 | 
						|
                if(p != null) p.stringValue = _servicesConfig.app_settings.android_store;
 | 
						|
 | 
						|
                p = n.serializedObject.FindProperty("PubmaticSetting.iOS.storeUrl");
 | 
						|
                if(p != null) p.stringValue = _servicesConfig.app_settings.ios_store;
 | 
						|
                
 | 
						|
                arr = _servicesConfig.ad_settings.pubmatic_ids_android;
 | 
						|
                if (IsArrayHasLength(arr, 3))
 | 
						|
                {
 | 
						|
                    p = n.serializedObject.FindProperty("PubmaticSetting.Android.bannerUnitID");
 | 
						|
                    p.stringValue = arr[0];
 | 
						|
                    p = n.serializedObject.FindProperty("PubmaticSetting.Android.interUnitID");
 | 
						|
                    p.stringValue = arr[1];
 | 
						|
                    p = n.serializedObject.FindProperty("PubmaticSetting.Android.rewardUnitID");
 | 
						|
                    p.stringValue = arr[2];
 | 
						|
                }
 | 
						|
 | 
						|
                arr = _servicesConfig.ad_settings.pubmatic_ids_ios;
 | 
						|
                if (IsArrayHasLength(arr, 3))
 | 
						|
                {
 | 
						|
                    p = n.serializedObject.FindProperty("PubmaticSetting.iOS.bannerUnitID");
 | 
						|
                    p.stringValue = arr[0];
 | 
						|
                    p = n.serializedObject.FindProperty("PubmaticSetting.iOS.interUnitID");
 | 
						|
                    p.stringValue = arr[1];
 | 
						|
                    p = n.serializedObject.FindProperty("PubmaticSetting.iOS.rewardUnitID");
 | 
						|
                    p.stringValue = arr[2];
 | 
						|
                }
 | 
						|
            }
 | 
						|
 | 
						|
            //---------- MOLOCO -----------------------
 | 
						|
            n = so.FindProperty("MolocoSetting");
 | 
						|
            if (null != n)
 | 
						|
            {
 | 
						|
                p = n.serializedObject.FindProperty("MolocoSetting.Enable");
 | 
						|
                p.boolValue = true;
 | 
						|
                
 | 
						|
                arr = _servicesConfig.ad_settings.moloco_ids_android;
 | 
						|
                if (IsArrayHasLength(arr, 3))
 | 
						|
                {
 | 
						|
                    p = n.serializedObject.FindProperty("MolocoSetting.Android.bannerTestUnitID");
 | 
						|
                    p.stringValue = arr[0];
 | 
						|
                    p = n.serializedObject.FindProperty("MolocoSetting.Android.interTestUnitID");
 | 
						|
                    p.stringValue = arr[1];
 | 
						|
                    p = n.serializedObject.FindProperty("MolocoSetting.Android.rewardTestUnitID");
 | 
						|
                    p.stringValue = arr[2];
 | 
						|
                }
 | 
						|
 | 
						|
                arr = _servicesConfig.ad_settings.moloco_ids_ios;
 | 
						|
                if (IsArrayHasLength(arr, 3))
 | 
						|
                {
 | 
						|
                    p = n.serializedObject.FindProperty("MolocoSetting.iOS.bannerTestUnitID");
 | 
						|
                    p.stringValue = arr[0];
 | 
						|
                    p = n.serializedObject.FindProperty("MolocoSetting.iOS.interTestUnitID");
 | 
						|
                    p.stringValue = arr[1];
 | 
						|
                    p = n.serializedObject.FindProperty("MolocoSetting.iOS.rewardTestUnitID");
 | 
						|
                    p.stringValue = arr[2];
 | 
						|
                }
 | 
						|
            }
 | 
						|
            
 | 
						|
            //---------- TRADPLUS -----------------------
 | 
						|
            n = so.FindProperty("TradplusSetting");
 | 
						|
            if (null != n)
 | 
						|
            {
 | 
						|
                arr = _servicesConfig.ad_settings.tradplus_ids_android;
 | 
						|
                if (IsArrayHasLength(arr, 3))
 | 
						|
                {
 | 
						|
                    p = n.serializedObject.FindProperty("TradplusSetting.Android.bannerUnitID");
 | 
						|
                    p.stringValue = arr[0];
 | 
						|
                    p = n.serializedObject.FindProperty("TradplusSetting.Android.interUnitID");
 | 
						|
                    p.stringValue = arr[1];
 | 
						|
                    p = n.serializedObject.FindProperty("TradplusSetting.Android.rewardUnitID");
 | 
						|
                    p.stringValue = arr[2];
 | 
						|
                }
 | 
						|
                
 | 
						|
                arr = _servicesConfig.ad_settings.tradplus_ids_ios;
 | 
						|
                if (IsArrayHasLength(arr, 3))
 | 
						|
                {
 | 
						|
                    p = n.serializedObject.FindProperty("TradplusSetting.iOS.bannerUnitID");
 | 
						|
                    p.stringValue = arr[0];
 | 
						|
                    p = n.serializedObject.FindProperty("TradplusSetting.iOS.interUnitID");
 | 
						|
                    p.stringValue = arr[1];
 | 
						|
                    p = n.serializedObject.FindProperty("TradplusSetting.iOS.rewardUnitID");
 | 
						|
                    p.stringValue = arr[2];
 | 
						|
                }
 | 
						|
            }
 | 
						|
 | 
						|
            //----------- ADSettings -------------------
 | 
						|
            n = so.FindProperty("ADSetting");
 | 
						|
            if (null != n)
 | 
						|
            {
 | 
						|
                p = n.serializedObject.FindProperty("ADSetting.SDK_KEY");
 | 
						|
                p.stringValue = _servicesConfig.ad_settings.sdk_key;
 | 
						|
                
 | 
						|
                arr = _servicesConfig.ad_settings.max_ids_android;
 | 
						|
                if(IsArrayHasLength(arr, 3))
 | 
						|
                {
 | 
						|
                    p = n.serializedObject.FindProperty("ADSetting.Android_Banner_ID");
 | 
						|
                    p.stringValue = arr[0];
 | 
						|
                    p = n.serializedObject.FindProperty("ADSetting.Android_Interstitial_ID");
 | 
						|
                    p.stringValue = arr[1];
 | 
						|
                    p = n.serializedObject.FindProperty("ADSetting.Android_Rewarded_ID");
 | 
						|
                    p.stringValue = arr[2];
 | 
						|
                }
 | 
						|
                
 | 
						|
                arr = _servicesConfig.ad_settings.max_ids_ios;
 | 
						|
                if (IsArrayHasLength(arr, 3))
 | 
						|
                {
 | 
						|
                    p = n.serializedObject.FindProperty("ADSetting.IOS_Banner_ID");
 | 
						|
                    p.stringValue = arr[0];
 | 
						|
                    p = n.serializedObject.FindProperty("ADSetting.IOS_Interstitial_ID");
 | 
						|
                    p.stringValue = arr[1];
 | 
						|
                    p = n.serializedObject.FindProperty("ADSetting.IOS_Rewarded_ID");
 | 
						|
                    p.stringValue = arr[2];
 | 
						|
                }
 | 
						|
            }
 | 
						|
            
 | 
						|
            //----------- AdjustSetting -------------------
 | 
						|
            n = so.FindProperty("AdjustSetting");
 | 
						|
            if (null != n 
 | 
						|
                && IsArrayHasLength(_servicesConfig.adjust_settings.app_token, 2))
 | 
						|
            {
 | 
						|
                p = n.serializedObject.FindProperty("AdjustSetting.androidAppToken");
 | 
						|
                p.stringValue = _servicesConfig.adjust_settings.app_token[0];
 | 
						|
                
 | 
						|
                p = n.serializedObject.FindProperty("AdjustSetting.iOSAppToken");
 | 
						|
                p.stringValue = _servicesConfig.adjust_settings.app_token[1];
 | 
						|
            }
 | 
						|
 | 
						|
            //----------- AnalyticsSetting -------------------
 | 
						|
            n = so.FindProperty("AnalyticsSetting");
 | 
						|
            if (null != n)
 | 
						|
            {
 | 
						|
                p = n.serializedObject.FindProperty("AnalyticsSetting.levelEndSuccessNum");
 | 
						|
                p.intValue = _servicesConfig.LevelEndSuccessNum();
 | 
						|
                p = n.serializedObject.FindProperty("AnalyticsSetting.enalbeFirebaseAnalytics");
 | 
						|
                p.boolValue = _servicesConfig.IsFirebaseEnabled();
 | 
						|
                p = n.serializedObject.FindProperty("AnalyticsSetting.enalbeFacebookAnalytics");
 | 
						|
                p.boolValue = _servicesConfig.IsFacebookEnabled();
 | 
						|
                p = n.serializedObject.FindProperty("AnalyticsSetting.enalbeAdjustAnalytics");
 | 
						|
                p.boolValue = _servicesConfig.IsAdjustEnabled();
 | 
						|
                p = n.serializedObject.FindProperty("AnalyticsSetting.adjustEventList");
 | 
						|
                if (null != p && IsArrayNotEmpty(_servicesConfig.adjust_settings.events))
 | 
						|
                {
 | 
						|
                    p.ClearArray();
 | 
						|
                    for (int i = 0; i < _servicesConfig.adjust_settings.events.Length; i++)
 | 
						|
                    {
 | 
						|
                        arr = _servicesConfig.adjust_settings.events[i].Split(',');
 | 
						|
                        if (IsArrayHasLength(arr, 3))
 | 
						|
                        {
 | 
						|
                            p.InsertArrayElementAtIndex(i);
 | 
						|
                            nn = p.GetArrayElementAtIndex(i).serializedObject;
 | 
						|
                            nn.FindProperty($"AnalyticsSetting.adjustEventList.Array.data[{i}].EventName").stringValue = arr[0];
 | 
						|
                            nn.FindProperty($"AnalyticsSetting.adjustEventList.Array.data[{i}].AndroidToken").stringValue = arr[1];
 | 
						|
                            nn.FindProperty($"AnalyticsSetting.adjustEventList.Array.data[{i}].IOSToken").stringValue = arr[2];
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
            
 | 
						|
            //---------------- Productions ------------------------
 | 
						|
            n = so.FindProperty("Products");
 | 
						|
            if (n != null && IsArrayNotEmpty(_servicesConfig.products))
 | 
						|
            {
 | 
						|
                n.ClearArray();
 | 
						|
                for (int i = 0; i < _servicesConfig.products.Length; i++)
 | 
						|
                {
 | 
						|
                    arr = _servicesConfig.products[i].Split(',');
 | 
						|
                    if (IsArrayHasLength(arr, 5))
 | 
						|
                    {
 | 
						|
                        n.InsertArrayElementAtIndex(i);
 | 
						|
                        nn = n.GetArrayElementAtIndex(i).serializedObject;
 | 
						|
                        nn.FindProperty($"Products.Array.data[{i}].ProductName").stringValue = arr[0];
 | 
						|
                        nn.FindProperty($"Products.Array.data[{i}].GooglePlayProductId").stringValue = arr[1];
 | 
						|
                        nn.FindProperty($"Products.Array.data[{i}].AppStoreProductId").stringValue = arr[2];
 | 
						|
                        nn.FindProperty($"Products.Array.data[{i}].Price").doubleValue = double.Parse(arr[3]);
 | 
						|
                        nn.FindProperty($"Products.Array.data[{i}].Type").enumValueIndex = int.Parse(arr[4]);
 | 
						|
                        nn.FindProperty($"Products.Array.data[{i}].Category").stringValue = "Store";
 | 
						|
                        nn.FindProperty($"Products.Array.data[{i}].IsFree").boolValue = false;
 | 
						|
                        
 | 
						|
                        //----- Extends Columes ------
 | 
						|
                        if (arr.Length > 5) 
 | 
						|
                            nn.FindProperty($"Products.Array.data[{i}].Category").stringValue = arr[5];
 | 
						|
                        if (arr.Length > 6)
 | 
						|
                            nn.FindProperty($"Products.Array.data[{i}].IsFree").boolValue = arr[6].ToLower() == "1" || arr[6].ToLower() == "true";
 | 
						|
                    } 
 | 
						|
                }
 | 
						|
            }
 | 
						|
 | 
						|
            //------- Save SO ----------
 | 
						|
            so.ApplyModifiedProperties();
 | 
						|
            EditorUtility.SetDirty(settings);
 | 
						|
            AssetDatabase.SaveAssetIfDirty(settings);
 | 
						|
        }
 | 
						|
 | 
						|
        //------------------------- AppLovinSettings --------------------------------
 | 
						|
        private void ImportAppLovinSettings()
 | 
						|
        {
 | 
						|
            EditorPrefs.SetBool(KeyMaxAutoUpdateEnabled, false); // 关闭Max自动升级功能
 | 
						|
            
 | 
						|
            AppLovinSettings settings = null;
 | 
						|
            if (IsAssetExists(nameof(AppLovinSettings), APPLOVIN_SETTINGS_PATH))
 | 
						|
            {
 | 
						|
                settings = AssetDatabase.LoadAssetAtPath<AppLovinSettings>(APPLOVIN_SETTINGS_PATH);
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                settings = CreateInstance<AppLovinSettings>();
 | 
						|
                AssetDatabase.CreateAsset(settings, APPLOVIN_SETTINGS_PATH);
 | 
						|
            }
 | 
						|
 | 
						|
            settings.SetAttributionReportEndpoint = true;
 | 
						|
            settings.QualityServiceEnabled = true;
 | 
						|
            settings.AddApsSkAdNetworkIds = true;
 | 
						|
            settings.SdkKey = _servicesConfig.ad_settings.sdk_key;
 | 
						|
            if (IsArrayHasLength(_servicesConfig.ad_settings.admob_app_id, 2))
 | 
						|
            {
 | 
						|
                settings.AdMobAndroidAppId = _servicesConfig.ad_settings.admob_app_id[0];
 | 
						|
                settings.AdMobIosAppId = _servicesConfig.ad_settings.admob_app_id[1];
 | 
						|
            }
 | 
						|
            settings.ConsentFlowEnabled = false;
 | 
						|
            EditorUtility.SetDirty(settings);
 | 
						|
            AssetDatabase.SaveAssetIfDirty(settings);
 | 
						|
        }
 | 
						|
 | 
						|
        //------------------------- FacebookSettings --------------------------------
 | 
						|
        private void ImportFacebookSettings()
 | 
						|
        {
 | 
						|
            FacebookSettings settings = null;
 | 
						|
            if (IsAssetExists(nameof(FacebookSettings), FACEBOOK_SETTINGS_PATH))
 | 
						|
            {
 | 
						|
                settings = AssetDatabase.LoadAssetAtPath<FacebookSettings>(FACEBOOK_SETTINGS_PATH);
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                settings = CreateInstance<FacebookSettings>();
 | 
						|
                AssetDatabase.CreateAsset(settings, FACEBOOK_SETTINGS_PATH);
 | 
						|
            }
 | 
						|
 | 
						|
            var so = new SerializedObject(settings);
 | 
						|
            SerializedProperty n;
 | 
						|
            
 | 
						|
            n = so.FindProperty("appLabels");
 | 
						|
            if (n != null)
 | 
						|
            {
 | 
						|
                n.ClearArray();
 | 
						|
                n.InsertArrayElementAtIndex(0);
 | 
						|
                n.GetArrayElementAtIndex(0).stringValue = _servicesConfig.app_settings.product_name;
 | 
						|
            }
 | 
						|
 | 
						|
            n = so.FindProperty("appIds");
 | 
						|
            if (n != null)
 | 
						|
            {
 | 
						|
                n.ClearArray();
 | 
						|
                n.InsertArrayElementAtIndex(0);
 | 
						|
                n.GetArrayElementAtIndex(0).stringValue = _servicesConfig.fb_settings.fb_app_id;
 | 
						|
            }
 | 
						|
            
 | 
						|
            n = so.FindProperty("clientTokens");
 | 
						|
            if (n != null)
 | 
						|
            {
 | 
						|
                n.ClearArray();
 | 
						|
                n.InsertArrayElementAtIndex(0);
 | 
						|
                n.GetArrayElementAtIndex(0).stringValue = _servicesConfig.fb_settings.fb_client_token;
 | 
						|
            }
 | 
						|
            
 | 
						|
            n = so.FindProperty("androidKeystorePath");
 | 
						|
            n.stringValue = ANDROID_KEYSTORE_PATH;
 | 
						|
            DeployKeystore();
 | 
						|
            
 | 
						|
            Facebook.Unity.Editor.ManifestMod.GenerateManifest(); // 重新生成 Manifest
 | 
						|
            
 | 
						|
            so.ApplyModifiedProperties();
 | 
						|
            EditorUtility.SetDirty(settings);
 | 
						|
            AssetDatabase.SaveAssetIfDirty(settings);
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        private void DeployKeystore()
 | 
						|
        {
 | 
						|
            var from = "Packages/com.guru.unity.sdk.core/Editor/BuildTool/guru_key.jks";
 | 
						|
            var to = ANDROID_KEYSTORE_PATH.Replace("Assets", Application.dataPath);
 | 
						|
            if (File.Exists(from) && !File.Exists(to))
 | 
						|
            {
 | 
						|
                File.Copy(from, to);
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        private void ApplyMods()
 | 
						|
        {
 | 
						|
            PlayerSettings.applicationIdentifier = _servicesConfig.app_settings.bundle_id; // 设置包名
 | 
						|
 | 
						|
// #if UNITY_ANDROID
 | 
						|
            //-------- 部署 Android 相关的文件和资源 ----------
 | 
						|
            AndroidManifestMod.Apply();
 | 
						|
            AndroidProjectMod.Apply();
 | 
						|
            AndroidResMod.Apply(); // 部署 GuruSDKRes 资源文件, 目前部署在 guru.sdk.core 的 Plugins/Android/SDKRes.androidlib 中
 | 
						|
// #endif
 | 
						|
 | 
						|
            AssetDatabase.Refresh();
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region GUI Utils
 | 
						|
        
 | 
						|
 | 
						|
        private void GUI_Color(Color color, Action content)
 | 
						|
        {
 | 
						|
            var c = GUI.color;
 | 
						|
            GUI.color = color;
 | 
						|
            content?.Invoke();
 | 
						|
            GUI.color = c;
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        private void GUI_Button(string label, Action content, Color color, GUIStyle style = null, params GUILayoutOption[] options)
 | 
						|
        {
 | 
						|
            GUI_Color(color, ()=> GUI_Button(label, content, style, options));
 | 
						|
        }
 | 
						|
        private void GUI_Button(string label, Action content, GUIStyle style = null, params GUILayoutOption[] options)
 | 
						|
        {
 | 
						|
            if (style != null)
 | 
						|
            {
 | 
						|
                if (GUILayout.Button(label,style, options))
 | 
						|
                {
 | 
						|
                    content?.Invoke();
 | 
						|
                }
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                if (GUILayout.Button(label, options))
 | 
						|
                {
 | 
						|
                    content?.Invoke();
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region Utils
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 获取Assets路径
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="filter"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        private static bool IsAssetExists(string typeName, string defaultPath)
 | 
						|
        {
 | 
						|
            bool result = false;
 | 
						|
            var guids = AssetDatabase.FindAssets($"t:{typeName}");
 | 
						|
            string p = "";
 | 
						|
            if (guids != null && guids.Length > 0)
 | 
						|
            {
 | 
						|
                for (int i = 0; i < guids.Length; i++)
 | 
						|
                {
 | 
						|
                    p = AssetDatabase.GUIDToAssetPath(guids[i]);
 | 
						|
                    if (File.Exists(p))
 | 
						|
                    {
 | 
						|
                        if (p == defaultPath)
 | 
						|
                        {
 | 
						|
                            result = true;
 | 
						|
                        }
 | 
						|
                        else
 | 
						|
                        {
 | 
						|
                            File.Delete(p);
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
            return result;
 | 
						|
        }
 | 
						|
 | 
						|
        private static bool IsArrayNotEmpty(Array array)
 | 
						|
        {
 | 
						|
            if (array == null) return false;
 | 
						|
            if (array.Length == 0) return false;
 | 
						|
            return true;
 | 
						|
        }
 | 
						|
 | 
						|
        private static bool IsArrayHasLength(Array array, int length)
 | 
						|
        {
 | 
						|
            if(!IsArrayNotEmpty(array)) return false;
 | 
						|
            return array.Length >= length;
 | 
						|
        }
 | 
						|
 | 
						|
        private static void EnsureParentDirectory(string filePath)
 | 
						|
        {
 | 
						|
            var dir = Path.GetDirectoryName(filePath);
 | 
						|
            if (!Directory.Exists(dir))
 | 
						|
            {
 | 
						|
                Directory.CreateDirectory(dir);
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
        
 | 
						|
    }
 | 
						|
} |