public bool doAuth(string username, string password) { if (string.IsNullOrEmpty(getCurrentAuthToken())) { var login = new Login(username, password); string authToken; try { authToken = login.Parse(makeCall(login)).token; } catch (CallException e) { Debug.LogError("error getting login auth token:" + e.Message); return(false); } context.addNamedMapping <string>(NamedInjections.API_TOKEN, authToken); } if (allLanguagesSupported == null) { getLanguageList(); if (allLanguagesSupported == null) { return(false); } } return(true); }
private static void ErrorReceived(object sender, DataReceivedEventArgs e) { if (e.Data != null && e.Data != string.Empty) { Debug.LogError("Error::" + e.Data); } }
internal static IntPtr FindWindowWithThreadProcessId(int processId) { var window = new IntPtr(); Win32Helpers.EnumWindows(delegate(IntPtr wnd, IntPtr param) { var windowProcessId = 0; Win32Helpers.GetWindowThreadProcessId(wnd, out windowProcessId); if (windowProcessId != processId || !IsMainWindow(wnd)) { return(true); } window = wnd; return(false); }, IntPtr.Zero); if (window.Equals(IntPtr.Zero)) { Debug.LogError("Could not find any window with process id " + processId); } return(window); }
public override bool Run(FileInfo buildTarget) { var startInfo = new ProcessStartInfo(); startInfo.Arguments = $"\"{buildTarget.FullName.Trim('\"')}\""; startInfo.FileName = Path.GetFullPath(Path.Combine(UnityEditor.EditorApplication.applicationContentsPath, "MonoBleedingEdge", "bin", "mono")); startInfo.WorkingDirectory = buildTarget.Directory.FullName; if (!startInfo.EnvironmentVariables.ContainsKey("LD_LIBRARY_PATH")) startInfo.EnvironmentVariables.Add("LD_LIBRARY_PATH","."); startInfo.CreateNoWindow = true; startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; var process = new Process(); process.StartInfo = startInfo; process.OutputDataReceived += (_, args) => Debug.Log(args.Data); process.ErrorDataReceived += (_, args) => Debug.LogError(args.Data); var success = process.Start(); if (!success) return false; process.BeginOutputReadLine(); process.BeginErrorReadLine(); return true; }
public string GetRule(string key) { var randomGenerator = new Random(); var randomNumber = randomGenerator.NextDouble(); double probabilityTotal = 0; if (Rules.ContainsKey(key) == false) { return(key); } for (int i = 0; i < Rules[key].Count; ++i) { var ruleProbability = Rules[key][i].Probability; if (randomNumber < ruleProbability + probabilityTotal) { return(Rules[key][i].Rule); } probabilityTotal += randomNumber; } Debug.LogError("Critical: Failed to get rule for LSystem. Please check probabilities are correctly initialised"); return("Error"); }
public IAPOfferInfo(string infoString) : this() { if (string.IsNullOrEmpty(infoString)) { return; } try { var pars = infoString.Split(','); float pp; int ia; long st, et; ProductId = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(pars[0])); ProductPrice = float.TryParse(pars[1], out pp) ? pp : 0f; ItemName = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(pars[2])); ItemAmount = int.TryParse(pars[3], out ia) ? ia : 0; StartTime = (long.TryParse(pars[4], out st) ? st : 0).ToDateTime(); EndTime = (long.TryParse(pars[5], out et) ? et : 0).ToDateTime(); Metadata = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(pars[6])); } catch (Exception e) { Debug.LogError("FuseSDK: Error parsing IAPOfferInfo. Returning default value."); Debug.LogException(e); return; } }
/// <summary>Returns the URL for the given size.</summary> public string GetSizeURL(LogoSize size) { switch (size) { case LogoSize.Original: { return(this.original); } case LogoSize.Thumbnail_320x180: { return(this.thumbnail_320x180); } case LogoSize.Thumbnail_640x360: { return(this.thumbnail_640x360); } case LogoSize.Thumbnail_1280x720: { return(this.thumbnail_1280x720); } default: { Debug.LogError("[mod.io] Unrecognized LogoSize"); return(string.Empty); } } }
public SfbFileSystemEntry CreateNewFileAndAddEntry(string path) { if (entries.ContainsKey(path)) { Debug.LogWarning("File already exists"); return(null); } SfbFileSystemEntry entry = new SfbFileSystemEntry(path, false, SfbFileSystemEntryType.File); #if !UNITY_WEBGL && !UNITY_WEBPLAYER if (!IsFake) { try { File.Create(path); } catch (Exception e) { Debug.LogException(e); Debug.LogError("Could not create file"); return(null); } } #endif AddEntry(entry); return(entry); }
public void ReadFileOrBackupFromDisk(SfbFileSystemEntry fileSystemEntry, string backupExtension) { #if !UNITY_WEBGL && !UNITY_WEBPLAYER if (string.IsNullOrEmpty(backupExtension)) { Debug.LogError("Cannot read backup file bacause no backup extension was set."); return; } if (fileSystemEntry.type != SfbFileSystemEntryType.File) { return; } if (!backupExtension.StartsWith(".")) { backupExtension = "." + backupExtension; } if (!File.Exists(fileSystemEntry.path)) { if (File.Exists(fileSystemEntry.path + backupExtension)) { fileSystemEntry.SetContents(File.ReadAllBytes(fileSystemEntry.path + backupExtension)); } return; } fileSystemEntry.ReadContentsFromDisk(); #endif }
protected override void Clean(string path, string root, Stream input, Stream output) { try { Process process; FilterMode mode; if (!processes.TryGetValue(path, out process)) { Debug.Log("Could not find lfs process for path: " + path + " when cleaning"); return; } if (!modes.TryGetValue(path, out mode)) { Debug.Log("Could not find lfs filter mode for path: " + path + " when cleaning"); return; } if (mode != FilterMode.Clean) { Debug.LogError("Filter mode mismatch when cleaning for path: " + path); } // write file data to stdin input.CopyTo(process.StandardInput.BaseStream); input.Flush(); } catch (Exception e) { Debug.LogError("LFS Clean Error!"); Debug.LogException(e); } }
public static IEnumerable <PathParameter> CallAllMethods() { var pathParams = new List <PathParameter>(); var methods = AppDomain.CurrentDomain.GetAssemblies() // Returns all currently loaded assemblies .SelectMany(x => x.GetTypes()) // returns all types defined in this assemblies .Where(x => x.IsClass && x.GetCustomAttributes(typeof(BuildPathProviderAttribute), false).FirstOrDefault() != null) // only yields classes .SelectMany(x => x.GetMethods()).Where(x => x.IsStatic) // returns all methods defined in those classes .Where(x => x.GetCustomAttributes(typeof(BuildPathAttribute), false).FirstOrDefault() != null); foreach (var method in methods) // iterate through all found methods { var resp = method.Invoke(null, null); // invoke the method if (resp is PathParameter pathParameter) { pathParams.Add(pathParameter); } else { Debug.LogError($"Wrong type! myst be {nameof(PathParameter)} but used {resp.GetType()}"); } } return(pathParams); }
/// <summary> /// Asserts if obj is null. Works only when Debugger is Enabled. /// </summary> /// <param name="obj">Object to check.</param> /// <param name="name">Name of a object</param> /// <param name="context">Context for a check (usually containing class).</param> public static void AssertNotNull(object obj, string name, Object context) { if (Enabled && (obj == null || obj.Equals(null))) { Debug.LogError(name + " in object " + context.name + " ( " + context.GetType() + " ) is null!", context); } }
/// <summary> /// Writes error to console. Works only when Debugger is Enabled. /// </summary> /// <param name="message">Error to write.</param> /// <param name="context">Context.</param> public static void LogError(string message, Object context = null) { if (LogLevelEnabled(LogLevel.Error)) { Debug.LogError(message, context); } }
private static void GenerateWhitelistInternal() { #if ACTK_DEBUG sw = Stopwatch.StartNew(); sw.Stop(); Debug.Log("=== Injection Detector Whitelist Build Start ==="); sw.Start(); #endif EditorUtility.DisplayProgressBar(ProgressCaption, "Gathering assemblies", 0); var assembliesInBuild = GetAssembliesInBuild(); if (assembliesInBuild.Length == 0) { Debug.LogError(EditorTools.ConstructError("Can't find any assemblies in build!")); } var assembliesAllowedByUser = GetUserWhiteListAssemblies(); var allAllowedAssemblies = InjectionRoutines.MergeAllowedAssemblies(assembliesInBuild, assembliesAllowedByUser); EditorUtility.DisplayProgressBar(ProgressCaption, "Writing assemblies hashes", 0); WriteAllowedAssemblies(allAllowedAssemblies); #if ACTK_DEBUG sw.Stop(); Debug.Log(ACTkConstants.LogPrefix + "WhiteList build duration: " + sw.ElapsedMilliseconds + " ms."); #endif AssetDatabase.Refresh(); }
/// <summary> /// Runs the redirected process and waits for it to return. /// </summary> public int Run() { var(process, outputLog) = SetupProcess(); using (process) { Start(process); process.WaitForExit(); var trimmedOutput = outputLog?.ToString().TrimStart(); if (string.IsNullOrEmpty(trimmedOutput)) { return(process.ExitCode); } if (process.ExitCode == 0) { Debug.Log(trimmedOutput); } else { Debug.LogError(trimmedOutput); } return(process.ExitCode); } }
public static async Task <UserFile> CreateNewProfile() { Rest.RequestResponse res = await Rest.GetAsync("users/create"); Debug.Log("RES TYPE: " + res.Type()); Debug.Log("RES CODE: " + res.ResponseCode()); Debug.Log("RES PROTO: " + res.ProtocolVersion()); Debug.Log("RES DATA: " + res.ResponseData()); string contentType; res.Headers().TryGetValue("Content-Type", out contentType); if (res.ResponseCode() == 201 && contentType.Contains("application/x-mdm-keypair")) { // Create the certificate and private key c# objects X509Certificate2 c = PEMCertHelper.GetCertificateFromDualPEM(res.ResponseData()); // Use that to create the UserFile object return(new UserFile(c)); } else { // Maybe throw an Exception here? // Example causes: outdated server / wrong url / server offline Debug.LogError("USER CREATENEW PROFILE RES ERROR"); return(null); } }
public void Init(Logger logger) { Plugin.logger = logger; Plugin.logger.Info("Starting " + typeof(Plugin).Namespace); if (string.Compare(XRSettings.loadedDeviceName, "OpenVR", StringComparison.InvariantCultureIgnoreCase) != 0) { Plugin.logger.Warn($"Current VR SDK is not OpenVR ({XRSettings.loadedDeviceName}). {typeof(Plugin).Namespace} will not be activated."); return; } if (!OpenVRActionManager.isRunning) { Plugin.logger.Warn($"OpenVR is not running. {typeof(Plugin).Namespace} will not be activated."); return; } try { AddManifestToSteamConfig(); } catch (Exception ex) { Debug.LogError("Failed to configure manifest"); Debug.LogError(ex); } RegisterActionSet(); ApplyHarmonyPatches(); }
public ParabolaJob( NativeArray <float3x2> segments, ref int index, float a, float b, float xmin, float xmax, float3 pos, quaternion rot, int numSegments ) { int bufferSizeRequired = index + numSegments; if (segments.Length < bufferSizeRequired) { Debug.LogError($"Assertion failed: segments.Length:{segments.Length} < bufferSizeRequired:{bufferSizeRequired}"); } this.segments = segments.Slice(index, numSegments); this.a = a; this.b = b; this.xmin = xmin; this.xmax = xmax; this.pos = pos; this.rot = rot; this.numSegments = numSegments; index = bufferSizeRequired; }
public VGOfferInfo(string infoString) : this() { if (string.IsNullOrEmpty(infoString)) { return; } try { var pars = infoString.Split(','); float pp; int ia; long st, et; int cid, vgid; PurchaseCurrency = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(pars[0])); PurchasePrice = float.TryParse(pars[1], out pp) ? pp : 0f; ItemName = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(pars[2])); ItemAmount = int.TryParse(pars[3], out ia) ? ia : 0; StartTime = (long.TryParse(pars[4], out st) ? st : 0).ToDateTime(); EndTime = (long.TryParse(pars[5], out et) ? et : 0).ToDateTime(); CurrencyID = int.TryParse(pars[6], out cid) ? cid : 0; VirtualGoodID = int.TryParse(pars[7], out vgid) ? vgid : 0; Metadata = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(pars[8])); } catch (Exception e) { Debug.LogError("FuseSDK: Error parsing VGOfferInfo. Returning default value."); Debug.LogException(e); return; } }
/// <summary>Returns the URL for the given size.</summary> public string GetSizeURL(IconSize size) { switch (size) { case IconSize.Original: { return(this.original); } case IconSize.Thumbnail_64x64: { return(this.thumbnail_64x64); } case IconSize.Thumbnail_128x128: { return(this.thumbnail_128x128); } case IconSize.Thumbnail_256x256: { return(this.thumbnail_256x256); } default: { Debug.LogError("[mod.io] Unrecognized IconSize"); return(string.Empty); } } }
public static string StopSession(bool finish = true) { if (!s_SessionActive) { return(null); } s_SessionActive = false; Debug.Log("Stopping profiler session"); try { var info = XPerfStartInfo("-stop -d \"" + RecordingEtlFile + "\""); var proc = Process.Start(info); proc.WaitForExit(); if (proc.ExitCode != 0) { Debug.LogError("Closing profiler session failed!"); Process.Start(XPerfStartInfo("-cancel")); return(null); } } catch { Process.Start(XPerfStartInfo("-cancel")); Debug.Log("Recording failed"); throw; } if (finish) { FinishSession(); return(OutputFile); } return(null); }
public override void FetchData(DataFetcherParameters parameters) { if (!(parameters is TerrainImageFetcherParameters imageDataParameters)) { return; } var rasterTile = imageDataParameters.useRetina ? new RetinaRasterTile() : new RasterTile(); rasterTile.Initialize(_fileSource, imageDataParameters.cTile.CanonicalTileId, imageDataParameters.tilesetId, () => { if (imageDataParameters.cTile.CanonicalTileId != rasterTile.Id) { return; } if (rasterTile.HasError) { Debug.LogError("Terrain Image Error!"); } else { dataReceived(imageDataParameters.cTile, rasterTile); } }); }
public override bool Run(FileInfo buildTarget) { var startInfo = new ProcessStartInfo(); startInfo.FileName = buildTarget.FullName.Trim('.'); startInfo.WorkingDirectory = buildTarget.Directory.FullName; if (!startInfo.EnvironmentVariables.ContainsKey("LD_LIBRARY_PATH")) startInfo.EnvironmentVariables.Add("LD_LIBRARY_PATH","."); startInfo.CreateNoWindow = true; startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; var process = new Process(); process.StartInfo = startInfo; process.OutputDataReceived += (_, args) => Debug.Log(args.Data); process.ErrorDataReceived += (_, args) => Debug.LogError(args.Data); var success = process.Start(); if (!success) return false; process.BeginOutputReadLine(); process.BeginErrorReadLine(); return true; }
private static void LaunchApp(bool isServer, string arguments) { //Make sure the build exists string buildPath = GetBuildDir(); if (buildPath == null) { Debug.LogError("No build exists! Build one using `Tools -> Volt Unity Builder -> Volt Builder -> Build Player`"); return; } string buildDirWorking = Path.GetDirectoryName(buildPath); if (isServer) { arguments += " -batchmode -nographics"; #if UNITY_EDITOR_LINUX ProcessHelper.LaunchLinuxTerminalAndLaunchProcess(buildPath, arguments); return; #endif } Process.Start(new ProcessStartInfo { FileName = buildPath, Arguments = arguments, WorkingDirectory = buildDirWorking }); }
/// <summary>Returns the URL for the given size.</summary> public string GetSizeURL(UserAvatarSize size) { switch (size) { case UserAvatarSize.Original: { return(this.original); } case UserAvatarSize.Thumbnail_50x50: { return(this.thumbnail_50x50); } case UserAvatarSize.Thumbnail_100x100: { return(this.thumbnail_100x100); } default: { Debug.LogError("[mod.io] Unrecognized UserAvatarSize"); return(string.Empty); } } }
public void Execute() { int surfaceCount = 0; for (int nodeOrder = 0; nodeOrder < allBrushMeshIDs.Length; nodeOrder++) { int brushMeshHash = allBrushMeshIDs[nodeOrder]; if (brushMeshHash != 0 && brushMeshBlobs.TryGetValue(brushMeshHash, out var item)) { surfaceCount += item.brushMeshBlob.Value.polygons.Length; brushMeshLookup[nodeOrder] = item.brushMeshBlob; } else { if (brushMeshHash == 0) { // The brushMeshID is invalid: a Generator created/didn't update a TreeBrush correctly brushMeshLookup[nodeOrder] = ChiselBlobAssetReference <BrushMeshBlob> .Null; } else { // *should* never happen var indexOrder = allTreeBrushIndexOrders[nodeOrder]; var nodeID = indexOrder.compactNodeID; Debug.LogError($"Brush with ID {nodeID} has its brushMeshID set to {brushMeshHash}, which is not initialized."); brushMeshLookup[nodeOrder] = ChiselBlobAssetReference <BrushMeshBlob> .Null; } } } surfaceCountRef.Value = surfaceCount; }
/// <summary> /// 使用powerShell,换成bash ? /// cmd.exe不可用 /// 可使用多条命令 /// </summary> /// <param name="command"></param> public static bool RunPowershellCommand(string command) { using (Process process = new Process()) { process.StartInfo.FileName = CommonUtil.IsOSXEditor ? "/bin/bash" : "powershell"; //"powershell"; process.StartInfo.Arguments = command; process.StartInfo.CreateNoWindow = true; // 是否要查看powershell窗口执行过程 process.StartInfo.ErrorDialog = true; // 该值指示不能启动进程时是否向用户显示错误对话框 process.StartInfo.UseShellExecute = false; // 默认设置 // process.StartInfo.RedirectStandardError = true; //process.StartInfo.RedirectStandardInput = true; //process.StartInfo.RedirectStandardOutput = true; try { process.Start(); process.WaitForExit(); process.Close(); } catch (Exception e) { Debug.LogError(e); return(false); } } return(true); }
public static bool TryGetQosServersFromGzip(byte[] gzipData, out QosServer[] qosServers) { qosServers = null; if (gzipData == null || gzipData.Length == 0) { return(false); } try { using (var ms = new MemoryStream(gzipData)) using (var gs = new GZipStream(ms, CompressionMode.Decompress)) using (var sr = new StreamReader(gs)) { var decodedResult = sr.ReadToEnd(); return(TryGetQosServersFromJsonString(decodedResult, out qosServers)); } } catch (Exception e) { Debug.LogError("Unable to parse gzip stream: " + e.Message); return(false); } }
public static void Check(bool condition, string message) { if (!condition) { Debug.LogError($"Debug check failed: {message}"); } }
private static string GitCommandExecution(string command) { isWorkingOnTask = true; // Strings that will catch the output from our process. string output = "no-git"; string errorOutput = "no-git"; //Debug.Log(command); // Set up our processInfo to run the git command and log to output and errorOutput. ProcessStartInfo processInfo = new ProcessStartInfo("git", command) { CreateNoWindow = true, // We want no visible pop-ups UseShellExecute = false, // Allows us to redirect input, output and error streams RedirectStandardOutput = true, // Allows us to read the output stream RedirectStandardError = true // Allows us to read the error stream }; // Set up the Process currentProcess = new Process { StartInfo = processInfo }; try { currentProcess.Start(); // Try to start it, catching any exceptions if it fails } catch (Exception e) { isWorkingOnTask = false; // For now just assume its failed cause it can't find git. Debug.LogError("Git is not set-up correctly, required to be on PATH, and to be a git project."); throw e; } // Read the results back from the process so we can get the output and check for errors output = currentProcess.StandardOutput.ReadToEnd(); errorOutput = currentProcess.StandardError.ReadToEnd(); currentProcess.WaitForExit(); // Make sure we wait till the process has fully finished. currentProcess.Close(); // Close the process ensuring it frees it resources. isWorkingOnTask = false; // Check for failure due to no git setup in the project itself or other fatal errors from git. if (output.Contains("fatal") || output == "no-git") { Debug.LogError($"Command: git {command} Failed\n {errorOutput}"); throw new Exception($"Command: git {command} Failed\n {errorOutput}"); } // Log any errors. if (errorOutput != "") { Debug.LogError($"Git Error: Command: git {command} - {errorOutput}"); throw new Exception($"Command: git {command} Failed\n {errorOutput}"); } return(output); // Return the output from git. }