using UnityEngine; using UnityEditor; using UnityEditor.AddressableAssets; using System.IO; using Newtonsoft.Json; public class DebugConfig { private const string mustaphaStaicResUrl = "http://192.168.9.111:8080/{0}"; private const string mustaphaAddrUrl = "http://192.168.9.111:8080/{0}/{1}"; private const string mustaphaEventAPIUrl = "http://192.168.9.111:5292/"; private const string mustaphaRTMPid = "80000560"; private const string mustaphaRTMServerEndpoint = "rtm-nx-front.ilivedata.com:13321"; private const string mustaphaRTMHmacSecret = "7a1ba6bb85a4473d96fa4bf45b01f1dd"; private const string liubingStaicResUrl = "http://192.168.9.91:8080/{0}"; private const string liubingAddrUrl = "http://192.168.9.91:8080/{0}/{1}"; private const string liubingEventAPIUrl = "http://192.168.9.91:5292/"; private const string liubingRTMPid = "80000560"; private const string liubingRTMServerEndpoint = "rtm-nx-front.ilivedata.com:13321"; private const string liubingRTMHmacSecret = "7a1ba6bb85a4473d96fa4bf45b01f1dd"; private const string s101StaicResUrl = "http://192.168.9.101:8080/{0}"; private const string s101AddrUrl = "http://192.168.9.101:8080/{0}/{1}"; private const string s101EventAPIUrl = "http://192.168.9.101:5292/"; private const string s101RTMPid = "80000560"; private const string s101RTMServerEndpoint = "rtm-nx-front.ilivedata.com:13321"; private const string s101RTMHmacSecret = "7a1ba6bb85a4473d96fa4bf45b01f1dd"; private const string s101FuncUrl= "http://192.168.9.101:7071"; private const string s101FuncKey= "testKey"; private const string devStaicResUrl = "https://sls-cloudfunction-ap-beijing-code-1305151099.cos.ap-beijing.myqcloud.com/mini/{0}"; private const string devAddrUrl = "https://sls-cloudfunction-ap-beijing-code-1305151099.cos.ap-beijing.myqcloud.com/mini/{0}/Android"; private const string devEventAPIUrl = "http://62.234.191.215:5292/"; private const string devRTMPid = "80000560"; private const string devRTMServerEndpoint = "rtm-nx-front.ilivedata.com:13321"; private const string devRTMHmacSecret = "7a1ba6bb85a4473d96fa4bf45b01f1dd"; private const string devFuncUrl= "http://62.234.191.215:7071"; private const string devFuncKey= "testKey"; private const string timeShiftStaicResUrl = "https://sls-cloudfunction-ap-beijing-code-1305151099.cos.ap-beijing.myqcloud.com/dev/{0}"; private const string timeShiftAddrUrl = "https://sls-cloudfunction-ap-beijing-code-1305151099.cos.ap-beijing.myqcloud.com/dev/{0}/Android"; private const string timeShiftEventAPIUrl = "http://62.234.191.215:5294/"; private const string timeShiftRTMPid = "80000560"; private const string timeShiftRTMServerEndpoint = "rtm-nx-front.ilivedata.com:13321"; private const string timeShiftRTMHmacSecret = "7a1ba6bb85a4473d96fa4bf45b01f1dd"; private const string timeShiftFuncUrl= "http://62.234.191.215:7073"; private const string timeShiftFuncKey= "testKey"; [MenuItem("Tools/Open Debug Config Dir")] public static void OpenConfigDir() { var dir = new DirectoryInfo(Application.persistentDataPath); Debug.Log(dir.FullName); System.Diagnostics.Process.Start("explorer.exe", dir.FullName); } [MenuItem("Tools/Open Cache Dir")] public static void OpenCacheDir() { var chachingPath = new System.Collections.Generic.List(); Caching.GetAllCachePaths(chachingPath); if (chachingPath.Count > 0) { Debug.Log(chachingPath[0]); System.Diagnostics.Process.Start("explorer.exe", chachingPath[0]); } } [MenuItem("Tools/Clean Cache ")] public static void DeleteCaching() { Caching.ClearCache(); } [MenuItem("Tools/Debug/Mustaph Svr")] public static void MustaphSvr() { var config = new TmpClas(); config.EventApiURL = mustaphaEventAPIUrl; config.StaticResURL = string.Format(mustaphaStaicResUrl, VersionTool.PackVer); config.Custom_Addressable_URL = string.Format(mustaphaAddrUrl, VersionTool.PackVer, EditorUserBuildSettings.activeBuildTarget); config.RTMPid = mustaphaRTMPid; config.RTMServerEndpoint = mustaphaRTMServerEndpoint; config.RTMHmacSecret = mustaphaRTMHmacSecret; File.WriteAllText( DebugConfigPath, Newtonsoft.Json.JsonConvert.SerializeObject(config, Formatting.Indented) ); } [MenuItem("Tools/Debug/Mustaph Svr", true)] public static bool MustaphSvrValidation() { var config = Config; if (config != null && config.StaticResURL == string.Format(mustaphaStaicResUrl, VersionTool.PackVer)) Menu.SetChecked("Tools/Debug/Mustaph Svr", true); else Menu.SetChecked("Tools/Debug/Mustaph Svr", false); return true; } [MenuItem("Tools/Debug/Liubing Svr")] public static void LiubingSvr() { var config = new TmpClas(); config.EventApiURL = liubingEventAPIUrl; config.StaticResURL = string.Format(liubingStaicResUrl, VersionTool.PackVer); config.Custom_Addressable_URL = string.Format(liubingAddrUrl, VersionTool.PackVer, EditorUserBuildSettings.activeBuildTarget); config.RTMPid = liubingRTMPid; config.RTMServerEndpoint = liubingRTMServerEndpoint; config.RTMHmacSecret = liubingRTMHmacSecret; File.WriteAllText( DebugConfigPath, Newtonsoft.Json.JsonConvert.SerializeObject(config, Formatting.Indented) ); } [MenuItem("Tools/Debug/Liubing Svr", true)] public static bool LiubingSvrValidation() { var config = Config; if (config != null && config.StaticResURL == string.Format(liubingStaicResUrl, VersionTool.PackVer)) Menu.SetChecked("Tools/Debug/Liubing Svr", true); else Menu.SetChecked("Tools/Debug/Liubing Svr", false); return true; } [MenuItem("Tools/Debug/Svr 101")] public static void Svr101() { var config = new TmpClas(); config.EventApiURL = s101EventAPIUrl; config.StaticResURL = string.Format(s101StaicResUrl, VersionTool.PackVer); config.Custom_Addressable_URL = string.Format(s101AddrUrl, VersionTool.PackVer, EditorUserBuildSettings.activeBuildTarget); config.RTMPid = s101RTMPid; config.RTMServerEndpoint = s101RTMServerEndpoint; config.RTMHmacSecret = s101RTMHmacSecret; config.FuncUrl= s101FuncUrl; config.FuncKey= s101FuncKey; File.WriteAllText( DebugConfigPath, Newtonsoft.Json.JsonConvert.SerializeObject(config, Formatting.Indented) ); } [MenuItem("Tools/Debug/Svr 101", true)] public static bool Svr101Validation() { var config = Config; if (config != null && config.StaticResURL == string.Format(s101StaicResUrl, VersionTool.PackVer)) Menu.SetChecked("Tools/Debug/Svr 101", true); else Menu.SetChecked("Tools/Debug/Svr 101", false); return true; } [MenuItem("Tools/Debug/SvrProd")] public static void SvrProd() { if (File.Exists(DebugConfigPath)) { File.Delete(DebugConfigPath); } } [MenuItem("Tools/Debug/SvrProd", true)] public static bool SvrProdValidation() { var hasDebugConfig = File.Exists(DebugConfigPath); Menu.SetChecked("Tools/Debug/SvrProd", !hasDebugConfig); return true; } [MenuItem("Tools/Debug/Svr Dev")] public static void SvrDev() { if (File.Exists(DebugConfigPath)) { File.Delete(DebugConfigPath); } var config = new TmpClas(); config.EventApiURL = devEventAPIUrl; config.StaticResURL = string.Format(devStaicResUrl, VersionTool.PackVer); config.Custom_Addressable_URL = string.Format(devAddrUrl, VersionTool.PackVer, EditorUserBuildSettings.activeBuildTarget); config.RTMPid = devRTMPid; config.RTMServerEndpoint = devRTMServerEndpoint; config.RTMHmacSecret = devRTMHmacSecret; config.FuncUrl= devFuncUrl; config.FuncKey= devFuncKey; File.WriteAllText( DebugConfigPath, Newtonsoft.Json.JsonConvert.SerializeObject(config, Formatting.Indented) ); } [MenuItem("Tools/Debug/Svr Dev", true)] public static bool SvrDevValidation() { var config = Config; if (config != null && config.StaticResURL == string.Format(devStaicResUrl, VersionTool.PackVer)) Menu.SetChecked("Tools/Debug/Svr Dev", true); else Menu.SetChecked("Tools/Debug/Svr Dev", false); return true; } [MenuItem("Tools/Debug/Svr timeshift")] public static void SvrTimeshift() { if (File.Exists(DebugConfigPath)) { File.Delete(DebugConfigPath); } var config = new TmpClas(); config.EventApiURL = timeShiftEventAPIUrl; config.StaticResURL = string.Format(timeShiftStaicResUrl, VersionTool.PackVer); config.Custom_Addressable_URL = string.Format(timeShiftAddrUrl, VersionTool.PackVer, EditorUserBuildSettings.activeBuildTarget); config.RTMPid = timeShiftRTMPid; config.RTMServerEndpoint = timeShiftRTMServerEndpoint; config.RTMHmacSecret = timeShiftRTMHmacSecret; config.FuncUrl= timeShiftFuncUrl; config.FuncKey= timeShiftFuncKey; File.WriteAllText( DebugConfigPath, Newtonsoft.Json.JsonConvert.SerializeObject(config, Formatting.Indented) ); } [MenuItem("Tools/Debug/Svr timeshift", true)] public static bool SvrTimeshiftValidation() { var config = Config; if (config != null && config.StaticResURL == string.Format(timeShiftStaicResUrl, VersionTool.PackVer)) Menu.SetChecked("Tools/Debug/Svr timeshift", true); else Menu.SetChecked("Tools/Debug/Svr timeshift", false); return true; } [MenuItem("Tools/Quality/Ultra", false, 4)] static void SetQualityUltra() { QualityManager.ChangeQuality(3); } [MenuItem("Tools/Quality/High", false, 4)] static void SetQualityHigh() { QualityManager.ChangeQuality(2); } [MenuItem("Tools/Quality/Medium", false, 4)] static void SetQualityMeduim() { QualityManager.ChangeQuality(1); } [MenuItem("Tools/Quality/Low", false, 4)] static void SetQualityLow() { QualityManager.ChangeQuality(0); } private static string AssetServerDir { get { var parentDir = Directory.GetParent(Application.dataPath).Parent.FullName; return Path.Join(parentDir, "AssetsServer"); } } private static string DebugConfigPath { get { return Path.Join(Application.persistentDataPath, GConstant.V_Debug_Config_Path); } } private static TmpClas Config { get { if (File.Exists(DebugConfigPath)) { return Newtonsoft.Json.JsonConvert.DeserializeObject(File.ReadAllText(DebugConfigPath)); } return null; } } class TmpClas { public string StaticResURL; public string PlayFabTitle; public string EventApiURL; public string Origin_Addressable_URL; public string Custom_Addressable_URL; public string RTMPid; public string RTMServerEndpoint; public string RTMHmacSecret; public string CustomID; public string GM; public string FuncUrl; public string FuncKey; public TmpClas() { var settings = AddressableAssetSettingsDefaultObject.Settings; Origin_Addressable_URL = settings.RemoteCatalogLoadPath.GetValue(settings); PlayFabTitle = GConstant.V_Debug_PF_Title; CustomID = @"{{input}}"; GM = "1"; } public static TmpClas FromFile(string path) { return Newtonsoft.Json.JsonConvert.DeserializeObject(File.ReadAllText(path)); } } }