public string this[string key] { get { for (int i = Length - 1; i >= 0; i--) { if (keyValueList[i].Key == key) { return(keyValueList[i].Value); } } SDK.Log(LogLevel.Error, string.Format("Key does not exist '{0}'", key)); return(""); } set { for (int i = Length - 1; i >= 0; i--) { if (keyValueList[i].Key == key) { keyValueList[i] = new KeyValue(key, value); return; } } SDK.Log(LogLevel.Error, string.Format("Key does not exist '{0}'", key)); } }
private static void OnEnterPlaymode() { #if TRAIL SDK.Log(LogLevel.Debug, "Trail CLI", "Starting dev server!"); runDevServerRequest = new RunDevServerRequest(TrailConfig.InitDevServerPortOverride); runDevServerRequest.AddCallback((success, request) => { if (!success && !request.IsCanceled) { SDK.Log(LogLevel.Error, "Trail CLI", request.ErrorMessage); } }); EditorApplication.playModeStateChanged += (state) => { if (state == PlayModeStateChange.ExitingPlayMode && runDevServerRequest != null) { runDevServerRequest.Cancel(); runDevServerRequest = null; } }; EditorUtility.ClearProgressBar(); #endif }
private static void OnProcessExit(object sender, EventArgs e) { SDK.Log(LogLevel.Debug, "Trail CLI", "Daemon exited"); if (errorData.Count > 0) { SDK.Log(LogLevel.Error, "Trail CLI", "Daemon crashed:\n" + string.Join("\n", errorData)); } process = null; }
private static Process CreateProcess() { daemonPort = GetFreePort(); SDK.Log(LogLevel.Debug, "Trail CLI", "Launching daemon on port " + daemonPort); ProcessStartInfo start = new ProcessStartInfo(); start.Arguments = "daemon --port=" + daemonPort.ToString(); #if UNITY_EDITOR_WIN start.FileName = Application.dataPath + "\\Trail\\Editor\\CLI\\Trail CLI Windows.exe"; #elif UNITY_EDITOR_OSX start.FileName = Application.dataPath + "/Trail/Editor/CLI/Trail CLI MacOS"; #elif UNITY_EDITOR_LINUX start.FileName = Application.dataPath + "/Trail/Editor/CLI/Trail CLI Linux"; #else #error Unsupported platform #endif if (!System.IO.File.Exists(start.FileName)) { SDK.Log(LogLevel.Error, "Trail CLI", string.Format("File is missing at '{0}'", start.FileName)); } #if UNITY_EDITOR_OSX Action <string> unQuarantine = (string path) => { Process proc = new Process { StartInfo = new ProcessStartInfo { FileName = "xattr", Arguments = "-d com.apple.quarantine \"" + path + "\"", UseShellExecute = false, }, }; proc.Start(); proc.WaitForExit(1000); }; unQuarantine(start.FileName); unQuarantine("Assets/Trail/Editor/Plugins/Grpc.Core/runtimes/osx/x64/grpc_csharp_ext.bundle"); unQuarantine("Assets/Trail/Editor/Plugins/Grpc.Core/runtimes/osx/x86/grpc_csharp_ext.bundle"); #endif start.WindowStyle = ProcessWindowStyle.Hidden; start.CreateNoWindow = true; start.UseShellExecute = false; start.RedirectStandardOutput = true; start.RedirectStandardError = true; var process = Process.Start(start); process.EnableRaisingEvents = true; process.Exited += OnProcessExit; process.ErrorDataReceived += OnErrorDataReceived; process.BeginErrorReadLine(); return(process); }
/// <summary> /// Indicates if the game was launched from an invite and that invite has not yet been finalized by calling <c>FinalizeLoadingInvite()</c> or <c>LeaveParty()</c>. /// </summary> /// <returns><c>true</c> if the game was launched from an invite and the invite has not yet been finalized, false otherwise</returns> public static bool IsInviteLoading() { bool isLoading = false; var result = IsInviteLoading(out isLoading); if (result.IsError()) { SDK.Log(LogLevel.Error, "PartyKit::InviteIsLoading " + result.ToString()); } return(isLoading); }
/// <summary> /// Provides the latest party data. This will always be the latest party data update sent by the current party leader. /// </summary> /// <returns>The latest version of the party data sent by the party leader.</returns> public static PartyData GetPartyData() { PartyData partyData; var result = GetPartyData(out partyData); if (result.IsError()) { SDK.Log(LogLevel.Error, "PartyKit::GetPartyData " + result.ToString()); } return(partyData); }
public static void StopProcess() { if (process != null) { if (!process.HasExited) { SDK.Log(LogLevel.Debug, "Trail CLI", "Killing daemon"); process.Kill(); } process = null; } }
/// <summary> /// Returns the directory where to put files to be synchronized. /// </summary> /// <returns>Returns the path to the directory (usually /trail/cloud_storage).</returns> public static string GetCloudStoragePath() { var path = ""; var res = GetCloudStoragePath(out path); if (res.IsError()) { SDK.Log(LogLevel.Error, "GetCloudStoragePath returned with error: " + res); path = "cloud_storage"; } return(path); }
private void RunLatestBuild() { ClearStates(); var hasBuild = HasBuild(); if (!hasBuild) { return; } runBuildRequest = CLI.RunBuild(TrailBuild.BuildLocationPath); runBuildRequest.AddCallback((success, request) => { if (!success && !request.IsCanceled && !string.IsNullOrEmpty(request.ErrorMessage)) { SDK.Log(LogLevel.Error, "Trail CLI", request.ErrorMessage); } }); }
/// <summary> /// Simplified way to upload a build at given path to Trail. /// Make sure you already logged into Trail. /// </summary> /// <param name="buildPath">Specific path the build is located.</param> /// <returns></returns> public static CLI.UploadBuildRequest Upload(string buildPath) { if (!System.IO.Directory.Exists(buildPath)) { SDK.Log(LogLevel.Warning, "Trail Build", "Attempting to upload build, but no directory exists at: " + buildPath); return(null); } var request = CLI.UploadBuild(buildPath); request.AddCallback((success) => { if (success) { UpdateBuildCacheUpload(); } }); return(request); }
/// <summary> /// Simplified way to upload a build to Trail. /// Make sure you already logged into Trail. /// </summary> /// <returns></returns> public static CLI.UploadBuildRequest Upload() { if (!HasBuild()) { SDK.Log(LogLevel.Warning, "Trail Build", "Attempting to Upload a build, however no build found."); return(null); } var request = CLI.UploadBuild(cache.BuildLocationPath); request.AddCallback((success) => { if (success) { UpdateBuildCacheUpload(); } }); return(request); }
/// <summary> /// Sets the value of provided key. /// </summary> /// <param name="key">The key to apply new value to.</param> /// <param name="value">The new value to apply</param> /// <param name="addIfNotExist">Whether to add new item if key does not exist.</param> public void Set(string key, string value, bool addIfNotExist) { for (int i = Length - 1; i >= 0; i--) { if (keyValueList[i].Key == key) { keyValueList[i] = new KeyValue(key, value); return; } } if (addIfNotExist) { Add(key, value); } else { SDK.Log(LogLevel.Warning, "Cannot set value because the key does not exist"); } }
public KeyValue(string key, string value) { if (key.Length > KeyValueList.KEY_SIZE) { SDK.Log(LogLevel.Error, "KeyValueList, key is to long! Max size = " + KeyValueList.KEY_SIZE); this.Key = ""; } else { this.Key = key; } if (value.Length > KeyValueList.VALUE_SIZE) { SDK.Log(LogLevel.Error, "KeyValueList, value is to long! Max size = " + KeyValueList.VALUE_SIZE); this.Value = ""; } else { this.Value = value; } }
public static string GetTrailDirectory() { string[] asmdefGuids = AssetDatabase.FindAssets("t:asmdef", new string[] { "Assets" }); string asmdefGuid = asmdefGuids.FirstOrDefault((guid) => { string path = AssetDatabase.GUIDToAssetPath(guid); System.IO.FileInfo file = new System.IO.FileInfo(path); if (!file.Exists) { return(false); } return(file.Name == "Trail.asmdef"); }); if (string.IsNullOrEmpty(asmdefGuid)) { SDK.Log(LogLevel.Error, "Trail Editor", "Failed to find Trail directory. Have Trail.asmdef been deleted from the project?"); return(""); } System.IO.FileInfo asmdefFile = new System.IO.FileInfo(AssetDatabase.GUIDToAssetPath(asmdefGuid)); return(asmdefFile.DirectoryName.Replace("\\", "/")); }
private void UploadLatestBuild() { ClearStates(); var hasBuild = HasBuild(); if (!hasBuild) { return; } if (uploadBuildRequest != null && !uploadBuildRequest.IsComplete) { SDK.Log(LogLevel.Error, "Trail CLI", "Already uploading build, cancel build before attempting to upload a new build!"); return; } uploadBuildRequest = TrailBuild.Upload(); uploadBuildRequest.AddCallback((success, request) => { if (success) { EditorApplication.delayCall += () => Application.OpenURL(string.Format(MANAGE_DEV_AREA_URL_GAME, cache.selectedGameId)); } }); }