-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
dab36c0
commit 4f355f0
Showing
23 changed files
with
821 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,15 @@ | ||
name: Create Tag | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: Klemensas/action-autotag@stable | ||
with: | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,88 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace com.bbbirder.unityeditor | ||
{ | ||
public static class ConsoleUtils | ||
{ | ||
public const char PATH_SPLITTER = | ||
#if UNITY_EDITOR_WIN | ||
';' | ||
#elif UNITY_EDITOR_OSX | ||
':' | ||
#endif | ||
; | ||
static Dictionary<int, string> foreColor = new(){ | ||
{30, "#000000"}, //black | ||
{31, "#FF0000"}, //red | ||
{32, "#00FF00"}, //green | ||
{33, "#FFFF00"}, //yellow | ||
{34, "#0000FF"}, //blue | ||
{35, "#FF00FF"}, //magenta | ||
{36, "#00FFFF"}, //cyan | ||
{37, "#FFFFFF"}, //white | ||
}; | ||
|
||
/// <summary> | ||
/// Parse standard color log to unity color log | ||
/// </summary> | ||
/// <param name="input"></param> | ||
/// <returns></returns> | ||
public static string NormalizeColor(string input) | ||
{ | ||
var pattern = "\x1b" + @"\[(\d+;)?(\d+;)?(\d+)m"; | ||
return Regex.Replace(input, pattern, m => | ||
{ | ||
foreach (Capture g in m.Groups) | ||
{ | ||
if (int.TryParse(g.Value, out var c)) | ||
{ | ||
if (c is 0 or 39) return "</color>"; | ||
if (foreColor.TryGetValue(c, out var col)) return $"<color={col}>"; | ||
} | ||
} | ||
return m.Value; | ||
}); | ||
} | ||
|
||
/// <summary> | ||
/// When standard output encoding is not normalized, use this to guess the encoding on the fly. | ||
/// </summary> | ||
/// <param name="bytes"></param> | ||
/// <returns></returns> | ||
public unsafe static bool IsUTF8InsteadOf16(byte[] bytes) | ||
{ | ||
if (bytes.Length % 2 != 0) return true; // distinguish from utf-16 only | ||
if (!bytes.Any(b => b == 0)) | ||
{ | ||
_ = 0; | ||
} | ||
var c = 0; | ||
foreach (var b in bytes) | ||
{ | ||
if (c != 0) | ||
{ | ||
c--; | ||
if ((b & 0xc0) != 0x80) | ||
return false; | ||
} | ||
else | ||
{ | ||
if (b == 0) | ||
return false; | ||
float f = 0xff ^ b; | ||
int zcnt = (int)((*(uint*)&f << 1 >> 24) - 127); | ||
c = stackalloc[]{ | ||
-1,-1,-1,3,2,1,-1,0, | ||
}[zcnt]; | ||
if (c == -1) | ||
return false; | ||
} | ||
} | ||
|
||
return c == 0; | ||
} | ||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.