Skip to content

Commit a8bf8c4

Browse files
committed
Merge pull request #29 from StellaCannefax/StellaTigre-stringbuilder
Update DisplayInterface.cs - use StringBuilder instead of concatenation to print
2 parents 892e7d4 + 9063a98 commit a8bf8c4

1 file changed

Lines changed: 24 additions & 22 deletions

File tree

OSVR-Unity/Assets/OSVRUnity/src/DisplayInterface.cs

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
/// </copyright>
2020

2121
using System;
22+
using System.Text;
2223
using UnityEngine;
2324
using SimpleJSON;
2425

@@ -96,28 +97,29 @@ public DeviceDescriptor GetDeviceDescription()
9697
int rotate180 = parsedJsonDisplayParams["hmd"]["eyes"][0]["rotate_180"].AsInt;
9798

9899
//print
99-
string parsedJson = "FIELD OF VIEW:\n";
100-
parsedJson += "monocular_horizontal = " + monocularHorizontal + "\n";
101-
parsedJson += "monocular_vertical = " + monocularVertical + "\n";
102-
parsedJson += "overlap_percent = " + overlapPercent + "\n";
103-
parsedJson += "pitch_tilt = " + pitchTilt + "\n";
104-
parsedJson += "\nRESOLUTION\n";
105-
parsedJson += "width = " + width + "\n";
106-
parsedJson += "height = " + width + "\n";
107-
parsedJson += "video_inputs = " + videoInputs + "\n";
108-
parsedJson += "display_mode = " + displayMode + "\n";
109-
parsedJson += "\nDISTORTION\n";
110-
parsedJson += "k1_red = " + k1Red + "\n";
111-
parsedJson += "k1_green = " + k1Green + "\n";
112-
parsedJson += "k1_blue = " + k1Blue + "\n";
113-
parsedJson += "\nRENDERING\n";
114-
parsedJson += "left_roll = " + leftRoll + "\n";
115-
parsedJson += "right_roll = " + rightRoll + "\n";
116-
parsedJson += "\nEYES\n";
117-
parsedJson += "center_proj_x = " + centerProjX + "\n";
118-
parsedJson += "center_proj_y = " + centerProjY + "\n";
119-
parsedJson += "rotate_180 = " + rotate180 + "\n";
120-
Debug.Log("Parsed " + JsonDescriptorFile.name + ".json:\n" + parsedJson);
100+
StringBuilder jsonPrinter = new StringBuilder(64);
101+
jsonPrinter.Append("FIELD OF VIEW:\n")
102+
.Append("monocular_horizontal = ").AppendLine( monocularHorizontal.ToString() )
103+
.Append("monocular_vertical = ").AppendLine( monocularVertical.ToString() )
104+
.Append("overlap_percent = ").AppendLine( overlapPercent.ToString() )
105+
.Append("pitch_tilt = ").AppendLine( pitchTilt.ToString() )
106+
.Append("\nRESOLUTION\n")
107+
.Append("width = ").AppendLine( width.ToString() )
108+
.Append("height = ").AppendLine( height.ToString() )
109+
.Append("video_inputs = ").AppendLine( videoInputs.ToString() )
110+
.Append("display_mode = ").AppendLine( displayMode )
111+
.Append("\nDISTORTION\n")
112+
.Append("k1_red = ").AppendLine( k1Red.ToString() )
113+
.Append("k1_green = ").AppendLine( k1Green.ToString() )
114+
.Append("k1_blue = ").AppendLine( k1Blue.ToString() )
115+
.Append("\nRENDERING\n")
116+
.Append("left_roll = ").AppendLine( leftRoll.ToString() )
117+
.Append("right_roll = ").AppendLine( rightRoll.ToString() )
118+
.Append("\nEYES\n")
119+
.Append("center_proj_x = ").AppendLine( centerProjX.ToString() )
120+
.Append("center_proj_y = ").AppendLine( centerProjY.ToString() )
121+
.Append("rotate_180 = ").AppendLine( rotate180.ToString() );
122+
Debug.Log("Parsed " + JsonDescriptorFile.name + ".json:\n" + jsonPrinter.ToString());
121123

122124
//create a device descriptor object and store the parsed json
123125
DeviceDescriptor deviceDescriptor = new DeviceDescriptor();

0 commit comments

Comments
 (0)