-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
316 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
net = dotnet | ||
|
||
publish: | ||
$(net) publish -r linux-x64 -p:PublishSingleFile=true -c Release --output ./out/publish | ||
|
||
run: | ||
$(net) run | ||
|
||
build: | ||
$(net) publish -r linux-x64 -p:PublishSingleFile=true -c Debug --output ./out/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// System libraries | ||
using System; | ||
using System.Threading; | ||
using System.Diagnostics; | ||
using devunity.components; | ||
|
||
namespace devunity | ||
{ | ||
class Program | ||
{ | ||
// Definitions | ||
static Process[] processlist = Process.GetProcesses(); | ||
|
||
// Main function | ||
static int Main(string[] args) | ||
{ | ||
// Clear console | ||
Console.Clear(); | ||
|
||
// Save current color | ||
int origColor = (int) Console.ForegroundColor; | ||
|
||
// Print app info | ||
Console.ForegroundColor = ConsoleColor.DarkMagenta; | ||
Console.WriteLine("Devunity - by Rudra Saraswat"); | ||
Console.WriteLine("============================"); | ||
Console.WriteLine(); | ||
Console.ForegroundColor = (ConsoleColor) origColor; | ||
|
||
// Parse arguments | ||
if (!(args.Length == 0)) | ||
foreach (string arg in args) { | ||
switch (arg) { | ||
case "-pm": case "--process-monitor": | ||
UnityProcessMonitor.ProcessMonitor(); | ||
break; | ||
|
||
case "-rb": case "--report-bug": | ||
UnityBugReporter.BugReporter(); | ||
break; | ||
|
||
case "-ru": case "--restart-unity": | ||
UnityRestart.RestartUnity(); | ||
break; | ||
|
||
case "-gp": case "--get-process-status": | ||
UnityProcessStatus.ProcessStatus(); | ||
break; | ||
|
||
default: | ||
Console.ForegroundColor = ConsoleColor.Red; | ||
Console.WriteLine("ERROR: NO SUCH COMMAND"); | ||
return 127; | ||
} | ||
} | ||
else | ||
Console.WriteLine("Devunity is a program for debugging Unity7.\n\nSYNTAX:\n\n\tdevunity ARGUMENT\n\nwhere ARGUMENT stands for one of the following:\n\n\t-pm | --process-monitor: Unity Process Monitor\n\n\t-rb | --report-bug: Unity Bug Report Generator\n\n\t-ru | --restart-unity: Restart Unity\n\n\t-gp | --get-process-status: Detailed Process Status"); | ||
|
||
return 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// System libraries | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
|
||
namespace devunity.components | ||
{ | ||
public class UnityBugReporter | ||
{ | ||
// Main function | ||
public static void BugReporter() | ||
{ | ||
try { | ||
string fileToWrite = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds().ToString() + ".br"; | ||
|
||
Console.WriteLine("Writing to file " + fileToWrite); | ||
|
||
using (StreamWriter file = new StreamWriter(fileToWrite, false)) | ||
{ | ||
file.WriteLine("UNITY PROCESSES -->"); | ||
Process[] processlist = Process.GetProcesses(); | ||
foreach (Process process in processlist) | ||
{ | ||
if (process.ProcessName.Contains("unity")) | ||
{ | ||
file.WriteLine("Process Name: {0}; Memory usage: {1}", process.ProcessName, process.WorkingSet64); | ||
} | ||
} | ||
file.WriteLine(); | ||
Console.WriteLine("Please type the bug details:"); | ||
string bugDetails = Console.ReadLine(); | ||
file.WriteLine("BUG DETAILS -->"); | ||
file.WriteLine(bugDetails); | ||
file.WriteLine(); | ||
Console.WriteLine("Please enter the affected Unity7 program (if you do not know, please type 'do not know'):"); | ||
string affectedProgram = Console.ReadLine(); | ||
file.WriteLine("AFFECTED PROGRAM -->"); | ||
file.WriteLine(affectedProgram); | ||
Console.WriteLine("Please send the file (or its contents): " + fileToWrite + " when reporting the bug."); | ||
} | ||
} catch { | ||
Console.ForegroundColor = ConsoleColor.Red; | ||
Console.WriteLine("ERROR: FAILED"); | ||
Environment.Exit(-1); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// System libraries | ||
using System; | ||
using System.Threading; | ||
using System.Diagnostics; | ||
using devunity.includes; | ||
|
||
namespace devunity.components | ||
{ | ||
public class UnityProcessMonitor | ||
{ | ||
// Definitions | ||
static Process[] processlist = Process.GetProcesses(); | ||
|
||
// Main function | ||
public static void ProcessMonitor() | ||
{ | ||
// Clear console | ||
Console.Clear(); | ||
// Print info | ||
printInfo(); | ||
// Start printing debug info | ||
for (;;) | ||
{ | ||
printProcesses(); | ||
Thread.Sleep(1000); | ||
Console.Clear(); | ||
updateProcesses(); | ||
printInfo(); | ||
} | ||
} | ||
|
||
// Print info | ||
static void printInfo() | ||
{ | ||
// Save current color | ||
int origColor = (int) Console.ForegroundColor; | ||
// Print app info | ||
Console.ForegroundColor = ConsoleColor.DarkMagenta; | ||
Console.WriteLine("Devunity - by Rudra Saraswat"); | ||
Console.WriteLine("============================"); | ||
Console.WriteLine(); | ||
Console.ForegroundColor = (ConsoleColor) origColor; | ||
} | ||
|
||
// Print processes | ||
static void printProcesses() | ||
{ | ||
Table.PrintLine(); | ||
Table.PrintRow("Process", "ID", "Time Started"); | ||
Table.PrintLine(); | ||
foreach(Process process in processlist) | ||
{ | ||
if (process.ProcessName.Contains("unity")) | ||
{ | ||
Table.PrintRow(process.ProcessName, process.Id + "", process.StartTime.ToString("dd/MM/yyyy HH:mm:ss")); | ||
Table.PrintLine(); | ||
} | ||
} | ||
} | ||
|
||
static void updateProcesses() | ||
{ | ||
processlist = Process.GetProcesses(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// System libraries | ||
using System; | ||
using System.Diagnostics; | ||
|
||
namespace devunity.components | ||
{ | ||
public class UnityProcessStatus | ||
{ | ||
// Main function | ||
public static void ProcessStatus() | ||
{ | ||
Console.Write("Process to get status of: "); | ||
string pName = Console.ReadLine(); | ||
if (pName.Contains("unity")) | ||
{ | ||
try | ||
{ | ||
Process[] pArray = Process.GetProcessesByName(pName); | ||
foreach (Process p in pArray) | ||
{ | ||
Console.WriteLine($"{pName}:"); | ||
Console.WriteLine(); | ||
Console.WriteLine($" Process ID : {p.Id}"); | ||
Console.WriteLine($" Physical memory usage : {p.WorkingSet64}"); | ||
Console.WriteLine($" User processor time : {p.UserProcessorTime}"); | ||
Console.WriteLine($" Privileged processor time : {p.PrivilegedProcessorTime}"); | ||
Console.WriteLine($" Total processor time : {p.TotalProcessorTime}"); | ||
Console.WriteLine(" -----------------------------------------------------"); | ||
Console.WriteLine(); | ||
} | ||
|
||
} catch { | ||
Console.ForegroundColor = ConsoleColor.Red; | ||
Console.WriteLine("ERROR: NO SUCH PROCESS"); | ||
Environment.Exit(127); | ||
} | ||
} else { | ||
Console.ForegroundColor = ConsoleColor.Red; | ||
Console.WriteLine("ERROR: NOT A UNITY PROCESS"); | ||
Environment.Exit(-1); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// System libraries | ||
using System; | ||
using System.Diagnostics; | ||
|
||
namespace devunity.components | ||
{ | ||
public class UnityRestart | ||
{ | ||
// Main function | ||
public static void RestartUnity() | ||
{ | ||
Console.Write("Are you sure? Some apps might close. In a dual monitor setup, some apps might move to the other display. To proceed, press ENTER, and to cancel, press ^C."); | ||
Console.ReadLine(); | ||
|
||
new Process() | ||
{ | ||
StartInfo = new ProcessStartInfo | ||
{ | ||
FileName = "unity", | ||
UseShellExecute = false, | ||
CreateNoWindow = true, | ||
} | ||
}.Start(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<DebPackageArchitecture>amd64</DebPackageArchitecture> | ||
<PackagePrefix>devunity</PackagePrefix> | ||
<PackageName>devunity-0.1.0</PackageName> | ||
<Version>0.1.0</Version> | ||
<Authors>Rudra Saraswat</Authors> | ||
<Company>Unity7 Maintainers</Company> | ||
<Product>Devunity</Product> | ||
<Description>A debugging tool for Unity7</Description> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
|
||
namespace devunity.includes | ||
{ | ||
public class Table | ||
{ | ||
public static int tableWidth = 90; | ||
|
||
public static void PrintLine() | ||
{ | ||
Console.WriteLine(new string('-', tableWidth)); | ||
} | ||
|
||
public static void PrintRow(params string[] columns) | ||
{ | ||
int width = (tableWidth - columns.Length) / columns.Length; | ||
string row = "|"; | ||
|
||
foreach (string column in columns) | ||
{ | ||
row += AlignCentre(column, width) + "|"; | ||
} | ||
|
||
Console.WriteLine(row); | ||
} | ||
|
||
public static string AlignCentre(string text, int width) | ||
{ | ||
text = text.Length > width ? text.Substring(0, width - 3) + "..." : text; | ||
|
||
if (string.IsNullOrEmpty(text)) | ||
{ | ||
return new string(' ', width); | ||
} | ||
else | ||
{ | ||
return text.PadRight(width - (width - text.Length) / 2).PadLeft(width); | ||
} | ||
} | ||
} | ||
} |