-
-
Save todorok1/23765b8a3ac16f3c12f75908a3019eb9 to your computer and use it in GitHub Desktop.
ゲーミングDebug.Logのサンプルメソッド
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
/// <Summary> | |
/// 同じ行内で文字の色を変化させて出力します。 | |
/// </Summary> | |
public static void OutputLine(string msg, ColorCodeHolder.ColorToneName toneName) | |
{ | |
// 文字の色を定義した配列を取得します。 | |
string[] colorCodeArray = ColorCodeHolder.GetColorToneArray(toneName); | |
System.Text.StringBuilder sb = new System.Text.StringBuilder(); | |
for (int i = 0; i < msg.Length; i++) | |
{ | |
char targetChar = msg[i]; | |
// 1文字ずつ色を変えてループするようにします。 | |
int colorIndex = i % colorCodeArray.Length; | |
string colorName = colorCodeArray[colorIndex]; | |
sb.Append(GetColorTagPrefix(colorName)) | |
.Append(targetChar) | |
.Append(GetColorTagPostfix()); | |
} | |
// タグをつけたメッセージをコンソールに出力します。 | |
Debug.Log(sb.ToString()); | |
} | |
/// <Summary> | |
/// 色を変更するタグの開始タグを取得します。 | |
/// </Summary> | |
static string GetColorTagPrefix(string colorName) | |
{ | |
return $"<color={colorName}>"; | |
} | |
/// <Summary> | |
/// 色を変更するタグの終了タグを取得します。 | |
/// </Summary> | |
static string GetColorTagPostfix() | |
{ | |
return $"</color>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment