forked from Shardstone/trail-into-darkness
Added a bunch of utilities and modfief the character data structue
This commit is contained in:
36
Packages/com.jovian.utilties/Runtime/ArrayUtility.cs
Normal file
36
Packages/com.jovian.utilties/Runtime/ArrayUtility.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
|
||||
namespace Jovian.Utilities {
|
||||
|
||||
public static class ArrayUtility {
|
||||
public static string ListToString(this IList list, bool newLinePerEntry = false) {
|
||||
if(list == null) {
|
||||
return "<NULL>";
|
||||
}
|
||||
StringBuilder sb = new();
|
||||
sb.Append("[");
|
||||
sb.Append(list.Count);
|
||||
sb.Append("]{");
|
||||
if(newLinePerEntry) {
|
||||
sb.AppendLine();
|
||||
}
|
||||
for(int i = 0, c = list.Count; i < c; i++) {
|
||||
sb.Append(list[i]);
|
||||
if(i < c - 1) {
|
||||
if(newLinePerEntry) {
|
||||
sb.AppendLine(",");
|
||||
}
|
||||
else {
|
||||
sb.Append(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(newLinePerEntry) {
|
||||
sb.AppendLine();
|
||||
}
|
||||
sb.Append("}");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user