-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathunity-cloud-masterclass.html
More file actions
1939 lines (1689 loc) · 100 KB
/
unity-cloud-masterclass.html
File metadata and controls
1939 lines (1689 loc) · 100 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Unity Cloud Engineering Masterclass</title>
<meta property="og:title" content="Unity Cloud Engineering Masterclass">
<meta property="og:description" content="End-to-end guide to Unity cloud engineering — deployment, scaling, and infrastructure for real-time 3D applications.">
<meta property="og:image" content="../mathsGraph.jpg">
<meta property="og:type" content="article">
<style>
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Syne:wght@400;500;700;800&family=Inter:wght@300;400;500&display=swap');
:root {
--bg: #0a0c10;
--bg2: #0f1218;
--bg3: #161b24;
--panel: #1a2030;
--border: #232b3a;
--border2: #2d3a50;
--accent: #00d4ff;
--accent2: #7c3aed;
--accent3: #10b981;
--accent4: #f59e0b;
--red: #ef4444;
--text: #e2e8f0;
--text2: #94a3b8;
--text3: #64748b;
--code-bg: #0d1117;
--code-border: #1e2a3a;
--mono: 'JetBrains Mono', monospace;
--display: 'Syne', sans-serif;
--body: 'Inter', sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
background: var(--bg);
color: var(--text);
font-family: var(--body);
font-size: 15px;
line-height: 1.7;
display: flex;
min-height: 100vh;
}
/* SIDEBAR */
#sidebar {
width: 280px;
min-width: 280px;
background: var(--bg2);
border-right: 1px solid var(--border);
position: fixed;
top: 0; left: 0; bottom: 0;
overflow-y: auto;
z-index: 100;
display: flex;
flex-direction: column;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.sidebar-header {
padding: 24px 20px 20px;
border-bottom: 1px solid var(--border);
}
.sidebar-logo {
font-family: var(--display);
font-weight: 800;
font-size: 18px;
color: var(--accent);
letter-spacing: -0.5px;
line-height: 1.2;
}
.sidebar-logo span { color: var(--text2); font-weight: 400; font-size: 12px; display: block; margin-top: 4px; letter-spacing: 0.5px; text-transform: uppercase; }
.progress-bar-wrap {
margin-top: 14px;
background: var(--border);
border-radius: 3px;
height: 3px;
}
.progress-bar {
height: 3px;
background: linear-gradient(90deg, var(--accent), var(--accent2));
border-radius: 3px;
transition: width 0.4s ease;
width: 0%;
}
.nav-section {
padding: 6px 0;
}
.nav-section-label {
font-size: 10px;
font-weight: 500;
letter-spacing: 1.2px;
text-transform: uppercase;
color: var(--text3);
padding: 12px 20px 4px;
}
.nav-item {
display: flex;
align-items: center;
gap: 10px;
padding: 7px 20px;
cursor: pointer;
font-size: 13px;
color: var(--text2);
border-left: 2px solid transparent;
transition: all 0.15s;
text-decoration: none;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-item.active { color: var(--accent); border-left-color: var(--accent); background: rgba(0,212,255,0.06); }
.nav-item .dot {
width: 6px; height: 6px;
border-radius: 50%;
background: var(--border2);
flex-shrink: 0;
transition: background 0.15s;
}
.nav-item.active .dot { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
/* MAIN */
#main {
margin-left: 280px;
flex: 1;
max-width: 900px;
padding: 0 48px 120px;
}
/* HERO */
.hero {
padding: 72px 0 56px;
border-bottom: 1px solid var(--border);
margin-bottom: 56px;
}
.hero-tag {
display: inline-flex;
align-items: center;
gap: 8px;
font-size: 11px;
font-weight: 500;
letter-spacing: 1px;
text-transform: uppercase;
color: var(--accent);
background: rgba(0,212,255,0.1);
border: 1px solid rgba(0,212,255,0.2);
padding: 5px 12px;
border-radius: 20px;
margin-bottom: 20px;
}
.hero h1 {
font-family: var(--display);
font-size: 52px;
font-weight: 800;
line-height: 1.05;
letter-spacing: -2px;
background: linear-gradient(135deg, #ffffff 0%, #94a3b8 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 16px;
}
.hero p {
font-size: 17px;
color: var(--text2);
max-width: 620px;
line-height: 1.65;
}
.hero-meta {
display: flex;
gap: 24px;
margin-top: 28px;
flex-wrap: wrap;
}
.hero-chip {
display: flex;
align-items: center;
gap: 6px;
font-size: 12px;
color: var(--text3);
}
.hero-chip strong { color: var(--text2); font-weight: 500; }
/* SECTIONS */
.section {
margin-bottom: 72px;
scroll-margin-top: 40px;
}
.section-header {
display: flex;
align-items: baseline;
gap: 14px;
margin-bottom: 24px;
padding-bottom: 16px;
border-bottom: 1px solid var(--border);
}
.section-num {
font-family: var(--mono);
font-size: 12px;
color: var(--accent);
opacity: 0.7;
}
h2 {
font-family: var(--display);
font-size: 28px;
font-weight: 700;
letter-spacing: -0.8px;
color: var(--text);
}
h3 {
font-family: var(--display);
font-size: 18px;
font-weight: 700;
color: var(--text);
margin: 32px 0 12px;
letter-spacing: -0.3px;
}
h4 {
font-size: 13px;
font-weight: 500;
letter-spacing: 0.5px;
text-transform: uppercase;
color: var(--text3);
margin: 24px 0 10px;
}
p { color: var(--text2); margin-bottom: 14px; }
p strong { color: var(--text); font-weight: 500; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
/* CALLOUTS */
.callout {
border-radius: 8px;
padding: 16px 18px;
margin: 20px 0;
border-left: 3px solid;
font-size: 14px;
}
.callout p { margin: 0; }
.callout.info { background: rgba(0,212,255,0.06); border-color: var(--accent); }
.callout.info p { color: #7dd3e8; }
.callout.warn { background: rgba(245,158,11,0.06); border-color: var(--accent4); }
.callout.warn p { color: #d4a44c; }
.callout.danger { background: rgba(239,68,68,0.06); border-color: var(--red); }
.callout.danger p { color: #f87171; }
.callout.success { background: rgba(16,185,129,0.06); border-color: var(--accent3); }
.callout.success p { color: #6ee7b7; }
.callout-label {
font-size: 10px;
font-weight: 600;
letter-spacing: 1px;
text-transform: uppercase;
margin-bottom: 6px;
}
.callout.info .callout-label { color: var(--accent); }
.callout.warn .callout-label { color: var(--accent4); }
.callout.danger .callout-label { color: var(--red); }
.callout.success .callout-label { color: var(--accent3); }
/* CODE */
.code-block {
background: var(--code-bg);
border: 1px solid var(--code-border);
border-radius: 8px;
margin: 16px 0;
overflow: hidden;
font-family: var(--mono);
font-size: 13px;
}
.code-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 16px;
background: rgba(255,255,255,0.03);
border-bottom: 1px solid var(--code-border);
}
.code-lang {
font-size: 11px;
font-weight: 500;
letter-spacing: 0.5px;
text-transform: uppercase;
color: var(--text3);
}
.code-copy {
font-size: 11px;
color: var(--text3);
cursor: pointer;
background: none;
border: 1px solid var(--border);
padding: 3px 10px;
border-radius: 4px;
font-family: var(--body);
transition: all 0.15s;
cursor: pointer;
}
.code-copy:hover { color: var(--text); border-color: var(--border2); }
.code-copy.copied { color: var(--accent3); border-color: var(--accent3); }
pre {
padding: 18px 20px;
overflow-x: auto;
line-height: 1.6;
color: #a8b4c8;
}
pre::-webkit-scrollbar { height: 4px; }
pre::-webkit-scrollbar-track { background: transparent; }
pre::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.kw { color: #c792ea; }
.str { color: #c3e88d; }
.cmt { color: #546e7a; font-style: italic; }
.num { color: #f78c6c; }
.fn { color: #82aaff; }
.type { color: #ffcb6b; }
.op { color: #89ddff; }
.var { color: #eeffff; }
/* STEP CARDS */
.steps {
display: flex;
flex-direction: column;
gap: 2px;
margin: 20px 0;
}
.step {
display: flex;
gap: 16px;
padding: 16px 18px;
background: var(--bg3);
border: 1px solid var(--border);
border-radius: 8px;
align-items: flex-start;
}
.step-num {
width: 26px;
height: 26px;
background: rgba(0,212,255,0.12);
border: 1px solid rgba(0,212,255,0.25);
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
font-family: var(--mono);
font-size: 12px;
font-weight: 700;
color: var(--accent);
flex-shrink: 0;
margin-top: 1px;
}
.step-content { flex: 1; }
.step-title { font-weight: 500; color: var(--text); font-size: 14px; margin-bottom: 4px; }
.step-desc { font-size: 13px; color: var(--text2); margin: 0; }
/* ERROR TABLE */
.err-table {
width: 100%;
border-collapse: collapse;
margin: 16px 0;
font-size: 13px;
}
.err-table th {
text-align: left;
padding: 10px 14px;
background: var(--bg3);
border: 1px solid var(--border);
color: var(--text3);
font-size: 11px;
font-weight: 500;
letter-spacing: 0.5px;
text-transform: uppercase;
}
.err-table td {
padding: 12px 14px;
border: 1px solid var(--border);
vertical-align: top;
color: var(--text2);
}
.err-table tr:hover td { background: rgba(255,255,255,0.02); }
.err-table .err-code {
font-family: var(--mono);
color: var(--red);
font-size: 12px;
}
.err-table .fix-code {
font-family: var(--mono);
color: var(--accent3);
font-size: 12px;
}
/* ARCH DIAGRAM */
.arch-svg-wrap {
background: var(--bg3);
border: 1px solid var(--border);
border-radius: 10px;
padding: 24px;
margin: 24px 0;
}
/* PACKAGES GRID */
.pkg-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
margin: 16px 0;
}
.pkg-card {
background: var(--bg3);
border: 1px solid var(--border);
border-radius: 8px;
padding: 14px 16px;
}
.pkg-name {
font-family: var(--mono);
font-size: 12px;
color: var(--accent);
font-weight: 500;
margin-bottom: 4px;
}
.pkg-desc {
font-size: 12px;
color: var(--text3);
line-height: 1.5;
}
/* INSIGHT BOX */
.insight {
background: linear-gradient(135deg, rgba(124,58,237,0.1), rgba(0,212,255,0.06));
border: 1px solid rgba(124,58,237,0.3);
border-radius: 10px;
padding: 18px 20px;
margin: 20px 0;
}
.insight-label {
font-size: 10px;
font-weight: 600;
letter-spacing: 1px;
text-transform: uppercase;
color: var(--accent2);
margin-bottom: 8px;
}
.insight p { color: #c4b5fd; margin: 0; font-size: 14px; }
/* SCALING METRICS */
.metrics-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
margin: 20px 0;
}
.metric-card {
background: var(--bg3);
border: 1px solid var(--border);
border-radius: 8px;
padding: 16px;
text-align: center;
}
.metric-val {
font-family: var(--display);
font-size: 26px;
font-weight: 800;
color: var(--accent);
line-height: 1;
margin-bottom: 4px;
}
.metric-label {
font-size: 11px;
color: var(--text3);
text-transform: uppercase;
letter-spacing: 0.5px;
}
/* INLINE CODE */
code {
font-family: var(--mono);
font-size: 12.5px;
background: rgba(0,212,255,0.08);
border: 1px solid rgba(0,212,255,0.15);
padding: 1px 6px;
border-radius: 4px;
color: var(--accent);
}
/* TOC TRACKER */
.sticky-progress {
position: fixed;
top: 0; right: 0; left: 280px;
height: 2px;
background: linear-gradient(90deg, var(--accent), var(--accent2));
z-index: 200;
transform-origin: left;
transform: scaleX(0);
transition: transform 0.1s;
}
ul { padding-left: 20px; color: var(--text2); margin-bottom: 14px; }
ul li { margin-bottom: 6px; }
ul li strong { color: var(--text); font-weight: 500; }
ol { padding-left: 20px; color: var(--text2); margin-bottom: 14px; }
ol li { margin-bottom: 8px; }
hr { border: none; border-top: 1px solid var(--border); margin: 40px 0; }
</style>
</head>
<body>
<nav style="font-family:'DM Mono',monospace;font-size:0.7rem;padding:8px 16px;background:#1c1a16;color:#b8b0a4;border-bottom:1px solid #333;letter-spacing:0.03em;position:sticky;top:0;z-index:9999;">
<a href="../index.html" style="color:#cc4400;text-decoration:none;">KeGG</a>
<span style="color:#555;margin:0 6px;">/</span>
<span style="color:#b8b0a4;">Masterclasses</span>
<span style="color:#555;margin:0 6px;">/</span>
<span style="color:#f2ece0;">Unity Cloud Engineering Masterclass</span>
</nav>
<div class="sticky-progress" id="readProgress"></div>
<!-- SIDEBAR -->
<nav id="sidebar">
<div class="sidebar-header">
<div class="sidebar-logo">
Unity Cloud<br>
<span>Engineering Masterclass</span>
</div>
<div class="progress-bar-wrap">
<div class="progress-bar" id="progressBar"></div>
</div>
</div>
<div class="nav-section">
<div class="nav-section-label">Foundation</div>
<a class="nav-item active" href="#overview"><span class="dot"></span>Architecture Overview</a>
<a class="nav-item" href="#prerequisites"><span class="dot"></span>Prerequisites & Setup</a>
<a class="nav-item" href="#project-setup"><span class="dot"></span>Unity Project Setup</a>
<a class="nav-item" href="#ugs-dashboard"><span class="dot"></span>UGS Dashboard</a>
<a class="nav-item" href="#packages"><span class="dot"></span>Package Installation</a>
</div>
<div class="nav-section">
<div class="nav-section-label">Core Services</div>
<a class="nav-item" href="#authentication"><span class="dot"></span>Authentication</a>
<a class="nav-item" href="#lobby"><span class="dot"></span>Lobby Service</a>
<a class="nav-item" href="#relay"><span class="dot"></span>Relay Service</a>
<a class="nav-item" href="#netcode"><span class="dot"></span>Netcode for GameObjects</a>
<a class="nav-item" href="#cloud-save"><span class="dot"></span>Cloud Save</a>
<a class="nav-item" href="#remote-config"><span class="dot"></span>Remote Config</a>
</div>
<div class="nav-section">
<div class="nav-section-label">Battle-Hardening</div>
<a class="nav-item" href="#errors"><span class="dot"></span>Errors & Fixes</a>
<a class="nav-item" href="#scaling"><span class="dot"></span>Scaling Insights</a>
<a class="nav-item" href="#production"><span class="dot"></span>Production Checklist</a>
</div>
</nav>
<!-- MAIN CONTENT -->
<main id="main">
<div class="hero">
<div class="hero-tag">🎮 Soup to Nuts</div>
<h1>Unity Cloud<br>Engineering</h1>
<p>A hands-on masterclass building a full Unity Gaming Services proof of concept — Auth, Lobby, Relay, Netcode, Cloud Save, Remote Config — with every gotcha, fix, and scaling truth documented.</p>
<div class="hero-meta">
<div class="hero-chip">🗓 <strong>Unity 2023.2+</strong></div>
<div class="hero-chip">📦 <strong>UGS SDK 2.x</strong></div>
<div class="hero-chip">🌐 <strong>NGO 1.9+</strong></div>
<div class="hero-chip">⚡ <strong>Relay + Lobby</strong></div>
</div>
</div>
<!-- ═══════════════════════════════════════════ SECTION 1 -->
<section class="section" id="overview">
<div class="section-header">
<span class="section-num">01</span>
<h2>Architecture Overview</h2>
</div>
<p>Before writing a single line of C#, you need a mental map of what Unity Cloud actually <em>is</em>. The umbrella brand is <strong>Unity Gaming Services (UGS)</strong>. It's a suite of cloud backend services that Unity maintains so you don't have to spin up your own servers. Here's what we're building and how the pieces connect:</p>
<div class="arch-svg-wrap">
<svg width="100%" viewBox="0 0 800 420" xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="arr" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="5" markerHeight="5" orient="auto-start-reverse">
<path d="M2 1L8 5L2 9" fill="none" stroke="#00d4ff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</marker>
<marker id="arr2" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="5" markerHeight="5" orient="auto-start-reverse">
<path d="M2 1L8 5L2 9" fill="none" stroke="#7c3aed" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</marker>
<marker id="arr3" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="5" markerHeight="5" orient="auto-start-reverse">
<path d="M2 1L8 5L2 9" fill="none" stroke="#10b981" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</marker>
</defs>
<!-- CLIENT A -->
<rect x="20" y="160" width="120" height="56" rx="8" fill="#1a2030" stroke="#232b3a" stroke-width="0.5"/>
<text x="80" y="184" text-anchor="middle" font-family="Syne,sans-serif" font-size="12" font-weight="700" fill="#e2e8f0">Player A</text>
<text x="80" y="200" text-anchor="middle" font-family="JetBrains Mono,monospace" font-size="10" fill="#64748b">Unity Client</text>
<!-- CLIENT B -->
<rect x="20" y="240" width="120" height="56" rx="8" fill="#1a2030" stroke="#232b3a" stroke-width="0.5"/>
<text x="80" y="264" text-anchor="middle" font-family="Syne,sans-serif" font-size="12" font-weight="700" fill="#e2e8f0">Player B</text>
<text x="80" y="280" text-anchor="middle" font-family="JetBrains Mono,monospace" font-size="10" fill="#64748b">Unity Client</text>
<!-- UGS CLOUD REGION -->
<rect x="180" y="20" width="460" height="380" rx="14" fill="none" stroke="#2d3a50" stroke-width="1" stroke-dasharray="6 4"/>
<text x="410" y="44" text-anchor="middle" font-family="JetBrains Mono,monospace" font-size="10" fill="#64748b" letter-spacing="1">UGS CLOUD</text>
<!-- AUTH -->
<rect x="210" y="60" width="140" height="60" rx="8" fill="rgba(124,58,237,0.12)" stroke="rgba(124,58,237,0.4)" stroke-width="0.5"/>
<text x="280" y="83" text-anchor="middle" font-family="Syne,sans-serif" font-size="12" font-weight="700" fill="#c4b5fd">Authentication</text>
<text x="280" y="100" text-anchor="middle" font-family="JetBrains Mono,monospace" font-size="10" fill="#7c3aed">Player ID + Token</text>
<!-- LOBBY -->
<rect x="210" y="150" width="140" height="60" rx="8" fill="rgba(0,212,255,0.08)" stroke="rgba(0,212,255,0.3)" stroke-width="0.5"/>
<text x="280" y="173" text-anchor="middle" font-family="Syne,sans-serif" font-size="12" font-weight="700" fill="#7dd3e8">Lobby</text>
<text x="280" y="190" text-anchor="middle" font-family="JetBrains Mono,monospace" font-size="10" fill="#00d4ff">Room Discovery</text>
<!-- RELAY -->
<rect x="210" y="240" width="140" height="60" rx="8" fill="rgba(16,185,129,0.08)" stroke="rgba(16,185,129,0.3)" stroke-width="0.5"/>
<text x="280" y="263" text-anchor="middle" font-family="Syne,sans-serif" font-size="12" font-weight="700" fill="#6ee7b7">Relay</text>
<text x="280" y="280" text-anchor="middle" font-family="JetBrains Mono,monospace" font-size="10" fill="#10b981">P2P Punch-through</text>
<!-- CLOUD SAVE -->
<rect x="440" y="60" width="170" height="60" rx="8" fill="rgba(245,158,11,0.08)" stroke="rgba(245,158,11,0.3)" stroke-width="0.5"/>
<text x="525" y="83" text-anchor="middle" font-family="Syne,sans-serif" font-size="12" font-weight="700" fill="#fcd34d">Cloud Save</text>
<text x="525" y="100" text-anchor="middle" font-family="JetBrains Mono,monospace" font-size="10" fill="#f59e0b">Player Persistence</text>
<!-- REMOTE CONFIG -->
<rect x="440" y="150" width="170" height="60" rx="8" fill="rgba(239,68,68,0.08)" stroke="rgba(239,68,68,0.25)" stroke-width="0.5"/>
<text x="525" y="173" text-anchor="middle" font-family="Syne,sans-serif" font-size="12" font-weight="700" fill="#fca5a5">Remote Config</text>
<text x="525" y="190" text-anchor="middle" font-family="JetBrains Mono,monospace" font-size="10" fill="#ef4444">Live Tuning</text>
<!-- NETCODE (client side) -->
<rect x="440" y="240" width="170" height="60" rx="8" fill="#161b24" stroke="#2d3a50" stroke-width="0.5"/>
<text x="525" y="263" text-anchor="middle" font-family="Syne,sans-serif" font-size="12" font-weight="700" fill="#94a3b8">NGO Netcode</text>
<text x="525" y="280" text-anchor="middle" font-family="JetBrains Mono,monospace" font-size="10" fill="#64748b">Host/Client Logic</text>
<!-- ARROWS: clients to auth -->
<line x1="140" y1="172" x2="208" y2="88" stroke="#7c3aed" stroke-width="1" stroke-opacity="0.6" marker-end="url(#arr2)"/>
<line x1="140" y1="265" x2="208" y2="105" stroke="#7c3aed" stroke-width="1" stroke-opacity="0.4" marker-end="url(#arr2)"/>
<!-- ARROWS: clients to lobby -->
<line x1="140" y1="188" x2="208" y2="178" stroke="#00d4ff" stroke-width="1" stroke-opacity="0.5" marker-end="url(#arr)"/>
<line x1="140" y1="262" x2="208" y2="200" stroke="#00d4ff" stroke-width="1" stroke-opacity="0.4" marker-end="url(#arr)"/>
<!-- ARROWS: clients to relay -->
<line x1="140" y1="198" x2="208" y2="260" stroke="#10b981" stroke-width="1" stroke-opacity="0.5" marker-end="url(#arr3)"/>
<line x1="140" y1="270" x2="208" y2="266" stroke="#10b981" stroke-width="1.5" stroke-opacity="0.7" marker-end="url(#arr3)"/>
<!-- Lobby to Relay (join code flow) -->
<line x1="350" y1="180" x2="438" y2="180" stroke="#2d3a50" stroke-width="0.5" stroke-dasharray="4 3"/>
<!-- Auth to Cloud Save -->
<line x1="350" y1="88" x2="438" y2="88" stroke="#2d3a50" stroke-width="0.5" stroke-dasharray="4 3"/>
<!-- P2P bidirectional -->
<line x1="80" y1="216" x2="80" y2="240" stroke="#10b981" stroke-width="1" stroke-opacity="0.5"/>
<text x="100" y="232" font-family="JetBrains Mono,monospace" font-size="9" fill="#10b981" opacity="0.7">P2P via Relay</text>
<!-- Legend -->
<rect x="200" y="340" width="400" height="46" rx="6" fill="rgba(255,255,255,0.02)" stroke="#232b3a" stroke-width="0.5"/>
<line x1="218" y1="363" x2="248" y2="363" stroke="#7c3aed" stroke-width="1.5"/>
<text x="254" y="367" font-family="JetBrains Mono,monospace" font-size="10" fill="#94a3b8">Auth flow</text>
<line x1="320" y1="363" x2="350" y2="363" stroke="#00d4ff" stroke-width="1.5"/>
<text x="356" y="367" font-family="JetBrains Mono,monospace" font-size="10" fill="#94a3b8">Lobby flow</text>
<line x1="424" y1="363" x2="454" y2="363" stroke="#10b981" stroke-width="1.5"/>
<text x="460" y="367" font-family="JetBrains Mono,monospace" font-size="10" fill="#94a3b8">Relay/P2P flow</text>
</svg>
</div>
<div class="insight">
<div class="insight-label">🧠 Core Insight</div>
<p><strong>The mental model that unlocks everything:</strong> Lobby handles <em>discovery</em> (finding each other), Relay handles <em>transport</em> (talking to each other), and Netcode handles <em>logic</em> (what you say). Authentication is the passport that allows access to all three. These are separate services with separate SDKs that you glue together in your code.</p>
</div>
<h3>The Full Flow in Words</h3>
<div class="steps">
<div class="step">
<div class="step-num">1</div>
<div class="step-content">
<div class="step-title">Sign In (Authentication)</div>
<div class="step-desc">Both players sign in anonymously or via platform. UGS assigns each a permanent <code>PlayerId</code> and a short-lived JWT access token. Every subsequent API call uses this token.</div>
</div>
</div>
<div class="step">
<div class="step-num">2</div>
<div class="step-content">
<div class="step-title">Create / Join a Lobby</div>
<div class="step-desc">Player A creates a Lobby on UGS servers — a JSON document in the cloud listing room settings and players. Player B queries for lobbies and joins by Lobby ID or a short join code.</div>
</div>
</div>
<div class="step">
<div class="step-num">3</div>
<div class="step-content">
<div class="step-title">Allocate a Relay Server</div>
<div class="step-desc">The Host (Player A) calls Relay to allocate a relay server slot. Relay returns a <code>JoinCode</code>. Host saves this JoinCode into the Lobby's custom data so all lobby members can read it.</div>
</div>
</div>
<div class="step">
<div class="step-num">4</div>
<div class="step-content">
<div class="step-title">Client Fetches & Joins Relay</div>
<div class="step-desc">Player B polls or subscribes to the Lobby, reads the JoinCode, and calls Relay to join. Both sides now have <code>RelayServerData</code> objects they can hand to Netcode.</div>
</div>
</div>
<div class="step">
<div class="step-num">5</div>
<div class="step-content">
<div class="step-title">Start Netcode Transport</div>
<div class="step-desc">Both sides configure <code>UnityTransport</code> with their Relay data and call <code>StartHost()</code> / <code>StartClient()</code>. All game traffic now flows through the Relay DTLS tunnel — no IP exposure.</div>
</div>
</div>
<div class="step">
<div class="step-num">6</div>
<div class="step-content">
<div class="step-title">Persist & Configure</div>
<div class="step-desc">Cloud Save stores per-player data (XP, settings, progress). Remote Config lets you tweak game parameters (spawn rates, prices) without a client update.</div>
</div>
</div>
</div>
</section>
<!-- ═══════════════════════════════════════════ SECTION 2 -->
<section class="section" id="prerequisites">
<div class="section-header">
<span class="section-num">02</span>
<h2>Prerequisites & Setup</h2>
</div>
<p>Before touching Unity, set up your accounts and tools. Missing any of these is the #1 reason tutorials fail silently.</p>
<h3>What You Need</h3>
<div class="steps">
<div class="step">
<div class="step-num">✓</div>
<div class="step-content">
<div class="step-title">Unity Account (free)</div>
<div class="step-desc">Go to <a href="https://id.unity.com">id.unity.com</a> and create an account. This is the identity that owns your cloud project. One account = one dashboard. Keep it secure — it controls your billing.</div>
</div>
</div>
<div class="step">
<div class="step-num">✓</div>
<div class="step-content">
<div class="step-title">Unity Hub 3.x</div>
<div class="step-desc">Download from <a href="https://unity.com/download">unity.com/download</a>. Hub manages editor versions. Never install Unity editors directly — you'll lose version-switching superpowers.</div>
</div>
</div>
<div class="step">
<div class="step-num">✓</div>
<div class="step-content">
<div class="step-title">Unity Editor 2023.2 LTS or 6 (6000.x)</div>
<div class="step-desc">Install via Hub. UGS SDK 2.x is best-supported on these versions. <strong>Do not use 2022.x</strong> — several UGS packages require minimum 2023.1 API surface. LTS = Long Term Support = patches keep coming.</div>
</div>
</div>
<div class="step">
<div class="step-num">✓</div>
<div class="step-content">
<div class="step-title">Unity Dashboard</div>
<div class="step-desc">Navigate to <a href="https://cloud.unity.com">cloud.unity.com</a>. This is the UGS web console where you create projects, enable services, and set credentials. <strong>You will live here.</strong></div>
</div>
</div>
<div class="step">
<div class="step-num">✓</div>
<div class="step-content">
<div class="step-title">Git (Optional but Strongly Recommended)</div>
<div class="step-desc">Initialize a git repo before adding packages. The <code>Library/</code> folder will be 3–5 GB after imports. Your <code>.gitignore</code> must exclude it or you'll commit hundreds of megabytes.</div>
</div>
</div>
</div>
<div class="callout warn">
<div class="callout-label">⚠ Billing Gotcha</div>
<p>UGS has a free tier (Spark plan) that covers ~100 MAU. You will NOT be charged during development, but you need to watch your dashboard. The Relay service bills per GB of relayed data. A single developer testing will never exceed the free tier — but add real players and monitor it.</p>
</div>
</section>
<!-- ═══════════════════════════════════════════ SECTION 3 -->
<section class="section" id="project-setup">
<div class="section-header">
<span class="section-num">03</span>
<h2>Unity Project Setup</h2>
</div>
<p>Create a fresh 3D (or 3D Core) project. The template doesn't matter much for cloud work — we care about the scripting backend and package manager.</p>
<h3>Critical Project Settings</h3>
<p>After creating the project, immediately go to <strong>Edit → Project Settings → Player</strong> and configure:</p>
<div class="code-block">
<div class="code-header"><span class="code-lang">Project Settings</span><button class="code-copy" onclick="copyCode(this)">Copy</button></div>
<pre>Company Name: YourStudio <span class="cmt">// affects bundle ID</span>
Product Name: CloudPOC
Bundle ID: com.yourstudio.cloudpoc
Scripting Backend: IL2CPP <span class="cmt">// REQUIRED for production builds</span>
API Compatibility: .NET Standard 2.1</pre>
</div>
<div class="callout warn">
<div class="callout-label">⚠ Why IL2CPP Matters</div>
<p>Mono scripting backend works fine in the editor, but UGS SDK packages internally depend on IL2CPP code stripping behaviour in builds. Always test your actual build — editor play mode can mask missing assembly definitions that IL2CPP strips away. Add a <code>link.xml</code> if you see serialization errors in builds.</p>
</div>
<h3>The link.xml File</h3>
<p>Create this at <code>Assets/link.xml</code> to prevent IL2CPP from stripping UGS assemblies:</p>
<div class="code-block">
<div class="code-header"><span class="code-lang">XML — Assets/link.xml</span><button class="code-copy" onclick="copyCode(this)">Copy</button></div>
<pre><span class="str"><linker></span>
<span class="str"><assembly</span> <span class="kw">fullname</span>=<span class="str">"Unity.Services.Core"</span> <span class="kw">preserve</span>=<span class="str">"all"</span><span class="str">/></span>
<span class="str"><assembly</span> <span class="kw">fullname</span>=<span class="str">"Unity.Services.Authentication"</span> <span class="kw">preserve</span>=<span class="str">"all"</span><span class="str">/></span>
<span class="str"><assembly</span> <span class="kw">fullname</span>=<span class="str">"Unity.Services.Lobby"</span> <span class="kw">preserve</span>=<span class="str">"all"</span><span class="str">/></span>
<span class="str"><assembly</span> <span class="kw">fullname</span>=<span class="str">"Unity.Services.Relay"</span> <span class="kw">preserve</span>=<span class="str">"all"</span><span class="str">/></span>
<span class="str"><assembly</span> <span class="kw">fullname</span>=<span class="str">"Unity.Services.CloudSave"</span> <span class="kw">preserve</span>=<span class="str">"all"</span><span class="str">/></span>
<span class="str"><assembly</span> <span class="kw">fullname</span>=<span class="str">"Unity.Services.RemoteConfig"</span> <span class="kw">preserve</span>=<span class="str">"all"</span><span class="str">/></span>
<span class="str"><assembly</span> <span class="kw">fullname</span>=<span class="str">"Unity.Netcode.Runtime"</span> <span class="kw">preserve</span>=<span class="str">"all"</span><span class="str">/></span>
<span class="str"></linker></span></pre>
</div>
<h3>Connect to Unity Cloud</h3>
<p>Go to <strong>Edit → Project Settings → Services</strong>. Sign in with your Unity account, then either create a new cloud project or link to an existing one. This writes a <code>ProjectID</code> and <code>EnvironmentID</code> into your project settings — the SDK reads these at runtime to know which UGS tenant to hit.</p>
<div class="insight">
<div class="insight-label">🧠 Environments Insight</div>
<p>UGS has Environments (Production, Development, custom). <strong>Always develop in a non-Production environment.</strong> Your Lobby data, Cloud Save data, Remote Config values and even your player accounts are siloed per environment. Switching from Dev to Production resets everyone's data. Create a "Development" environment first and never ship builds that point to Production until you're ready.</p>
</div>
</section>
<!-- ═══════════════════════════════════════════ SECTION 4 -->
<section class="section" id="ugs-dashboard">
<div class="section-header">
<span class="section-num">04</span>
<h2>UGS Dashboard</h2>
</div>
<p>The UGS Dashboard at <a href="https://cloud.unity.com">cloud.unity.com</a> is your operations center. Here's what you must do before writing code:</p>
<div class="steps">
<div class="step">
<div class="step-num">1</div>
<div class="step-content">
<div class="step-title">Create a Project</div>
<div class="step-desc">Dashboard → Projects → New Project. Name it clearly. The Project ID (a UUID) is what the SDK uses — don't confuse it with the display name.</div>
</div>
</div>
<div class="step">
<div class="step-num">2</div>
<div class="step-content">
<div class="step-title">Enable Each Service</div>
<div class="step-desc">Navigate to each service (Authentication, Lobby, Relay, Cloud Save, Remote Config) and click "Enable". Services that aren't enabled return <code>403 Forbidden</code> — a confusing error when you don't know why.</div>
</div>
</div>
<div class="step">
<div class="step-num">3</div>
<div class="step-content">
<div class="step-title">Create Your Environments</div>
<div class="step-desc">Dashboard → Environments. Create "development" and later "production". Set <strong>development</strong> as the active environment in Unity editor via Project Settings → Services → Environment.</div>
</div>
</div>
<div class="step">
<div class="step-num">4</div>
<div class="step-content">
<div class="step-title">Configure Authentication Providers</div>
<div class="step-desc">Dashboard → Authentication → Settings. Enable "Anonymous" for now. Later add Apple, Google, Steam, etc. Each provider needs its own client ID/secret configured here.</div>
</div>
</div>
<div class="step">
<div class="step-num">5</div>
<div class="step-content">
<div class="step-title">Seed Remote Config Values</div>
<div class="step-desc">Dashboard → Remote Config. Add a key like <code>max_players</code> = <code>4</code>. You'll fetch this at runtime. If the key doesn't exist in the dashboard, the SDK returns a default you define in code.</div>
</div>
</div>
</div>
<div class="callout danger">
<div class="callout-label">🔥 Do Not Ship</div>
<p>Never hardcode your Project ID, API keys, or service credentials in client-side code that ships to players. Your Project ID is semi-public (it's in builds anyway), but any server-side keys or admin tokens must live in Cloud Code or your backend — never in the client binary.</p>
</div>
</section>
<!-- ═══════════════════════════════════════════ SECTION 5 -->
<section class="section" id="packages">
<div class="section-header">
<span class="section-num">05</span>
<h2>Package Installation</h2>
</div>
<p>Open the Package Manager (<strong>Window → Package Manager</strong>). Switch to "Unity Registry". Install these packages in order — some have dependencies that will resolve automatically:</p>
<div class="pkg-grid">
<div class="pkg-card">
<div class="pkg-name">com.unity.services.core</div>
<div class="pkg-desc">The root SDK. Initializes all UGS services. Must be installed first.</div>
</div>
<div class="pkg-card">
<div class="pkg-name">com.unity.services.authentication</div>
<div class="pkg-desc">Player sign-in and identity. Depends on core.</div>
</div>
<div class="pkg-card">
<div class="pkg-name">com.unity.services.lobby</div>
<div class="pkg-desc">Room creation, discovery, and matchmaking metadata.</div>
</div>
<div class="pkg-card">
<div class="pkg-name">com.unity.services.relay</div>
<div class="pkg-desc">NAT punch-through server allocation for P2P without IP exposure.</div>
</div>
<div class="pkg-card">
<div class="pkg-name">com.unity.services.cloudsave</div>
<div class="pkg-desc">Per-player (and public) key-value persistence in the cloud.</div>
</div>
<div class="pkg-card">
<div class="pkg-name">com.unity.services.remoteconfig</div>
<div class="pkg-desc">Fetch server-side config values without a client update.</div>
</div>
<div class="pkg-card">
<div class="pkg-name">com.unity.netcode.gameobjects</div>
<div class="pkg-desc">The Netcode for GameObjects (NGO) multiplayer framework.</div>
</div>
<div class="pkg-card">
<div class="pkg-name">com.unity.transport</div>
<div class="pkg-desc">Low-level transport layer. NGO + Relay both depend on this.</div>
</div>
</div>
<p>Alternatively, edit your <code>Packages/manifest.json</code> directly — faster and reproducible:</p>
<div class="code-block">
<div class="code-header"><span class="code-lang">JSON — Packages/manifest.json (dependencies section)</span><button class="code-copy" onclick="copyCode(this)">Copy</button></div>
<pre>{
<span class="str">"dependencies"</span>: {
<span class="str">"com.unity.services.core"</span>: <span class="str">"1.13.0"</span>,
<span class="str">"com.unity.services.authentication"</span>: <span class="str">"3.3.3"</span>,
<span class="str">"com.unity.services.lobby"</span>: <span class="str">"1.2.2"</span>,
<span class="str">"com.unity.services.relay"</span>: <span class="str">"1.3.1"</span>,
<span class="str">"com.unity.services.cloudsave"</span>: <span class="str">"3.2.1"</span>,
<span class="str">"com.unity.services.remoteconfig"</span>: <span class="str">"4.1.1"</span>,
<span class="str">"com.unity.netcode.gameobjects"</span>: <span class="str">"1.9.1"</span>,
<span class="str">"com.unity.transport"</span>: <span class="str">"2.3.0"</span>
}
}</pre>
</div>
<div class="callout info">
<div class="callout-label">💡 Version Pinning</div>
<p>Always pin exact versions in your manifest. UGS packages have had breaking API changes between minor versions (the lobby subscription API changed in 1.1.x → 1.2.x). Pin, then bump intentionally and read the changelog.</p>
</div>
</section>