Skip to content

Commit f4fe399

Browse files
committed
Added ArgList4 variant
1 parent 679de4f commit f4fe399

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

Assets/DebugOverlay/DebugOverlay.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ public static void Write<T0, T1, T2>(float x, float y, string format, T0 arg0, T
157157
instance._Write(x, y, format, new ArgList3<T0, T1, T2>(arg0, arg1, arg2));
158158
}
159159

160+
public static void Write<T0, T1, T2, T3>(float x, float y, string format, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
161+
{
162+
if (instance == null)
163+
return;
164+
instance._Write(x, y, format, new ArgList4<T0, T1, T2, T3>(arg0, arg1, arg2, arg3));
165+
}
166+
160167
// Draw a stacked histogram from numSets of data. Data must contain numSets of interleaved, non-negative datapoints.
161168
public static void DrawHist(float x, float y, float w, float h, float[] data, int startSample, Color[] color, int numSets, float maxRange = -1.0f)
162169
{

Assets/DebugOverlay/TextFormatter.cs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public unsafe interface IConverter<T>
1414
void Convert(ref char* dst, char* end, T value, FormatSpec formatSpec);
1515
}
1616

17-
public unsafe class Converter : IConverter<int>, IConverter<float>, IConverter<string>
17+
public unsafe class Converter : IConverter<int>, IConverter<float>, IConverter<string>, IConverter<byte>
1818
{
1919
public static Converter instance = new Converter();
2020

@@ -23,6 +23,11 @@ void IConverter<int>.Convert(ref char* dst, char* end, int value, FormatSpec for
2323
ConvertInt(ref dst, end, value, formatSpec.argWidth, formatSpec.integerWidth, formatSpec.leadingZero);
2424
}
2525

26+
void IConverter<byte>.Convert(ref char* dst, char* end, byte value, FormatSpec formatSpec)
27+
{
28+
ConvertInt(ref dst, end, value, formatSpec.argWidth, formatSpec.integerWidth, formatSpec.leadingZero);
29+
}
30+
2631
void IConverter<float>.Convert(ref char* dst, char* end, float value, FormatSpec formatSpec)
2732
{
2833
if (formatSpec.fractWidth == 0)
@@ -191,6 +196,32 @@ public void Format(ref char* dst, char* end, int argIndex, FormatSpec formatSpec
191196
}
192197
}
193198

199+
public unsafe struct ArgList4<T0, T1, T2, T3> : IArgList
200+
{
201+
public int Count { get { return 4; } }
202+
T0 t0;
203+
T1 t1;
204+
T2 t2;
205+
T3 t3;
206+
public ArgList4(T0 a0, T1 a1, T2 a2, T3 a3)
207+
{
208+
t0 = a0;
209+
t1 = a1;
210+
t2 = a2;
211+
t3 = a3;
212+
}
213+
public void Format(ref char* dst, char* end, int argIndex, FormatSpec formatSpec)
214+
{
215+
switch (argIndex)
216+
{
217+
case 0: (Converter.instance as IConverter<T0>).Convert(ref dst, end, t0, formatSpec); break;
218+
case 1: (Converter.instance as IConverter<T1>).Convert(ref dst, end, t1, formatSpec); break;
219+
case 2: (Converter.instance as IConverter<T2>).Convert(ref dst, end, t2, formatSpec); break;
220+
case 3: (Converter.instance as IConverter<T3>).Convert(ref dst, end, t3, formatSpec); break;
221+
}
222+
}
223+
}
224+
194225
/// <summary>
195226
/// Garbage free string formatter
196227
/// </summary>

0 commit comments

Comments
 (0)