17 private string roomName =
"New Room";
18 private Vector2 scrollViewVector = Vector2.zero;
19 private int padding = 4;
20 private int areaWidth = 400;
21 private int areaHeight = 300;
22 private int buttonWidth = 80;
23 private int lineHeight = 20;
25 private Vector2 anchorScrollVector = Vector2.zero;
26 private string anchorName =
"New Anchor";
27 private readonly byte[] anchorTestData =
new byte[5 * 1024 * 1024];
31 for (
int i = 0; i < anchorTestData.Length; ++i)
33 anchorTestData[i] = (byte)(i % 256);
40 if (sharingMgr != null)
58 private void OnDestroy()
67 scrollViewVector = GUI.BeginScrollView(
68 new Rect(25, 25, areaWidth, areaHeight),
70 new Rect(0, 0, areaWidth, areaHeight));
75 if (sessionMgr != null)
77 roomName = GUI.TextField(
78 new Rect(buttonWidth + padding, 0, areaWidth - (buttonWidth + padding), lineHeight),
81 if (GUI.Button(
new Rect(0, 0, buttonWidth, lineHeight),
"Create"))
88 Debug.LogWarning(
"Cannot create room");
98 int vOffset = (padding + lineHeight) * (i + 1);
101 bool keepOpen = GUI.Toggle(
new Rect(hOffset, vOffset, lineHeight, lineHeight), room.
GetKeepOpen(),
"");
104 hOffset += lineHeight + padding;
106 if (currentRoom != null && room.
GetID() == currentRoom.
GetID())
108 if (GUI.Button(
new Rect(hOffset, vOffset, buttonWidth, lineHeight),
"Leave"))
115 if (GUI.Button(
new Rect(hOffset, vOffset, buttonWidth, lineHeight),
"Join"))
119 Debug.LogWarning(
"Cannot join room");
124 hOffset += buttonWidth + padding;
126 GUI.Label(
new Rect(hOffset, vOffset, areaWidth - (buttonWidth + padding), lineHeight),
139 if (currentRoom != null)
142 anchorScrollVector = GUI.BeginScrollView(
143 new Rect(areaWidth + 50, 25, areaWidth, areaHeight),
145 new Rect(0, 0, areaWidth, areaHeight));
150 buttonWidth + padding,
152 areaWidth - (buttonWidth + padding),
156 if (GUI.Button(
new Rect(0, 0, buttonWidth, lineHeight),
"Create"))
158 if (!roomMgr.
UploadAnchor(currentRoom, anchorName, anchorTestData, anchorTestData.Length))
160 Debug.LogError(
"Failed to start anchor upload");
166 int vOffset = (padding + lineHeight) * (i + 1);
172 buttonWidth + padding,
174 areaWidth - (buttonWidth + padding),
178 if (GUI.Button(
new Rect(0, vOffset, buttonWidth, lineHeight),
"Download"))
182 Debug.LogWarning(
"Failed to start anchor download");
192 private void OnRoomAdded(
Room newRoom)
197 private void OnRoomClosed(
Room room)
202 private void OnUserJoinedRoom(
Room room,
int user)
208 private void OnUserLeftRoom(
Room room,
int user)
214 private void OnAnchorsChanged(
Room room)
227 Debug.LogFormat(
"Anchors download failed: {0}", failureReason.
GetString());
231 private void OnAnchorUploadComplete(
bool successful,
XString failureReason)
235 Debug.Log(
"Anchors upload succeeded");
239 Debug.LogFormat(
"Anchors upload failed: {0}", failureReason.
GetString());