Skip to content

Commit a8c196b

Browse files
hammerlerobiElfi0Kuhndorffernando-cortez
authored
Feat/distributed authority sample/vivox integration update (#258)
* recreation of vivox scripts from old PR * updating ServiceHelper to join channel * wip: Enable Vivox, voice and text working somehow without UI atm * wip: textchat working * feat: improve Chat * wip: Improve TextChat * wip: achitectural changes * wip: small improvements * chore: decouple TextChat from Services * chore: cleanup * feat: Block Player Input on Chat Input focused * fix: await Vivox Login * chore: remove unused files * chore: remove scene * fix: focus state on textfield * fix: improve initialization and handle session leave * chore: cleanup * fix: apply review changes * docs: add changelog entry * Update CHANGELOG.md Co-authored-by: Fernando Cortez <[email protected]> --------- Co-authored-by: Elfi Kühndorf <[email protected]> Co-authored-by: Fernando Cortez <[email protected]>
1 parent 022594f commit a8c196b

28 files changed

+831
-185
lines changed

Basic/DistributedAuthoritySocialHub/Assets/Prefabs/UI/IngameUI.prefab

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ Transform:
227227
- {fileID: 2256034313796960807}
228228
- {fileID: 7559383771208540613}
229229
- {fileID: 8481058004063830698}
230+
- {fileID: 6866794867799222920}
230231
m_Father: {fileID: 0}
231232
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
232233
--- !u!1 &5231826839060252271
@@ -378,3 +379,50 @@ MonoBehaviour:
378379
m_PanelMaxSize: 1
379380
m_DisplayYOffset: 1.8
380381
m_Camera: {fileID: 0}
382+
--- !u!1 &8792977535300992051
383+
GameObject:
384+
m_ObjectHideFlags: 0
385+
m_CorrespondingSourceObject: {fileID: 0}
386+
m_PrefabInstance: {fileID: 0}
387+
m_PrefabAsset: {fileID: 0}
388+
serializedVersion: 6
389+
m_Component:
390+
- component: {fileID: 6866794867799222920}
391+
- component: {fileID: 2710521362083790645}
392+
m_Layer: 0
393+
m_Name: TextChatUI
394+
m_TagString: Untagged
395+
m_Icon: {fileID: 0}
396+
m_NavMeshLayer: 0
397+
m_StaticEditorFlags: 0
398+
m_IsActive: 1
399+
--- !u!4 &6866794867799222920
400+
Transform:
401+
m_ObjectHideFlags: 0
402+
m_CorrespondingSourceObject: {fileID: 0}
403+
m_PrefabInstance: {fileID: 0}
404+
m_PrefabAsset: {fileID: 0}
405+
m_GameObject: {fileID: 8792977535300992051}
406+
serializedVersion: 2
407+
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
408+
m_LocalPosition: {x: 9.600002, y: -5.4000006, z: 0}
409+
m_LocalScale: {x: 1, y: 1, z: 1}
410+
m_ConstrainProportionsScale: 0
411+
m_Children: []
412+
m_Father: {fileID: 8617889547341104717}
413+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
414+
--- !u!114 &2710521362083790645
415+
MonoBehaviour:
416+
m_ObjectHideFlags: 0
417+
m_CorrespondingSourceObject: {fileID: 0}
418+
m_PrefabInstance: {fileID: 0}
419+
m_PrefabAsset: {fileID: 0}
420+
m_GameObject: {fileID: 8792977535300992051}
421+
m_Enabled: 1
422+
m_EditorHideFlags: 0
423+
m_Script: {fileID: 11500000, guid: 893a7d85794ab094798b16ae014c5d52, type: 3}
424+
m_Name:
425+
m_EditorClassIdentifier:
426+
m_UIDocument: {fileID: 436460152536684898}
427+
m_Asset: {fileID: 9197481963319205126, guid: e47914746c33245118570e272f51690a, type: 3}
428+
m_Messages: []

Basic/DistributedAuthoritySocialHub/Assets/Prefabs/Vivox.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!1 &4141237635811601714
4+
GameObject:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
serializedVersion: 6
10+
m_Component:
11+
- component: {fileID: 7448202836938688200}
12+
- component: {fileID: 8855226785007094250}
13+
m_Layer: 0
14+
m_Name: VivoxManager
15+
m_TagString: Untagged
16+
m_Icon: {fileID: 0}
17+
m_NavMeshLayer: 0
18+
m_StaticEditorFlags: 0
19+
m_IsActive: 1
20+
--- !u!4 &7448202836938688200
21+
Transform:
22+
m_ObjectHideFlags: 0
23+
m_CorrespondingSourceObject: {fileID: 0}
24+
m_PrefabInstance: {fileID: 0}
25+
m_PrefabAsset: {fileID: 0}
26+
m_GameObject: {fileID: 4141237635811601714}
27+
serializedVersion: 2
28+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
29+
m_LocalPosition: {x: 0, y: 0, z: 0}
30+
m_LocalScale: {x: 1, y: 1, z: 1}
31+
m_ConstrainProportionsScale: 0
32+
m_Children: []
33+
m_Father: {fileID: 0}
34+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
35+
--- !u!114 &8855226785007094250
36+
MonoBehaviour:
37+
m_ObjectHideFlags: 0
38+
m_CorrespondingSourceObject: {fileID: 0}
39+
m_PrefabInstance: {fileID: 0}
40+
m_PrefabAsset: {fileID: 0}
41+
m_GameObject: {fileID: 4141237635811601714}
42+
m_Enabled: 1
43+
m_EditorHideFlags: 0
44+
m_Script: {fileID: 11500000, guid: dde97419ba27cd44bae2dcde9387507b, type: 3}
45+
m_Name:
46+
m_EditorClassIdentifier:
47+
m_ParticipantPrefab: {fileID: 0}
48+
m_ParticipantListParent: {fileID: 0}

Basic/DistributedAuthoritySocialHub/Assets/Prefabs/Vivox/VivoxManager.prefab.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Basic/DistributedAuthoritySocialHub/Assets/Scenes/Bootstrap.unity

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ RenderSettings:
4242
--- !u!157 &3
4343
LightmapSettings:
4444
m_ObjectHideFlags: 0
45-
serializedVersion: 12
45+
serializedVersion: 13
46+
m_BakeOnSceneLoad: 0
4647
m_GISettings:
4748
serializedVersion: 2
4849
m_BounceScale: 1
@@ -147,8 +148,6 @@ MonoBehaviour:
147148
m_Script: {fileID: 11500000, guid: b5134217b751de44fb27f189c7ef29e2, type: 3}
148149
m_Name:
149150
m_EditorClassIdentifier:
150-
m_AutoAuthenticateOnStart: 1
151-
m_InitiateVivoxOnAuthentication: 1
152151
--- !u!4 &340021862
153152
Transform:
154153
m_ObjectHideFlags: 0
@@ -223,6 +222,7 @@ MonoBehaviour:
223222
m_Script: {fileID: 11500000, guid: 593a2fe42fa9d37498c96f9a383b6521, type: 3}
224223
m_Name:
225224
m_EditorClassIdentifier:
225+
NetworkManagerExpanded: 0
226226
NetworkConfig:
227227
ProtocolVersion: 0
228228
NetworkTransport: {fileID: 900326968}
@@ -246,8 +246,8 @@ MonoBehaviour:
246246
SpawnTimeout: 10
247247
EnableNetworkLogs: 1
248248
NetworkTopology: 1
249-
UseCMBService: 0
250-
AutoSpawnPlayerPrefabClientSide: 1
249+
UseCMBService: 1
250+
AutoSpawnPlayerPrefabClientSide: 0
251251
NetworkMessageMetrics: 1
252252
NetworkProfilingMetrics: 1
253253
OldPrefabList: []
@@ -268,9 +268,67 @@ Transform:
268268
m_Children: []
269269
m_Father: {fileID: 0}
270270
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
271+
--- !u!1001 &1475976338
272+
PrefabInstance:
273+
m_ObjectHideFlags: 0
274+
serializedVersion: 2
275+
m_Modification:
276+
serializedVersion: 3
277+
m_TransformParent: {fileID: 0}
278+
m_Modifications:
279+
- target: {fileID: 4141237635811601714, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
280+
propertyPath: m_Name
281+
value: VivoxManager
282+
objectReference: {fileID: 0}
283+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
284+
propertyPath: m_LocalPosition.x
285+
value: 0
286+
objectReference: {fileID: 0}
287+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
288+
propertyPath: m_LocalPosition.y
289+
value: 0
290+
objectReference: {fileID: 0}
291+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
292+
propertyPath: m_LocalPosition.z
293+
value: 0
294+
objectReference: {fileID: 0}
295+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
296+
propertyPath: m_LocalRotation.w
297+
value: 1
298+
objectReference: {fileID: 0}
299+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
300+
propertyPath: m_LocalRotation.x
301+
value: 0
302+
objectReference: {fileID: 0}
303+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
304+
propertyPath: m_LocalRotation.y
305+
value: 0
306+
objectReference: {fileID: 0}
307+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
308+
propertyPath: m_LocalRotation.z
309+
value: 0
310+
objectReference: {fileID: 0}
311+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
312+
propertyPath: m_LocalEulerAnglesHint.x
313+
value: 0
314+
objectReference: {fileID: 0}
315+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
316+
propertyPath: m_LocalEulerAnglesHint.y
317+
value: 0
318+
objectReference: {fileID: 0}
319+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
320+
propertyPath: m_LocalEulerAnglesHint.z
321+
value: 0
322+
objectReference: {fileID: 0}
323+
m_RemovedComponents: []
324+
m_RemovedGameObjects: []
325+
m_AddedGameObjects: []
326+
m_AddedComponents: []
327+
m_SourcePrefab: {fileID: 100100000, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
271328
--- !u!1660057539 &9223372036854775807
272329
SceneRoots:
273330
m_ObjectHideFlags: 0
274331
m_Roots:
275332
- {fileID: 340021862}
276333
- {fileID: 900326970}
334+
- {fileID: 1475976338}

Basic/DistributedAuthoritySocialHub/Assets/Scenes/HubScene_TownMarket.unity

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,63 @@ MonoBehaviour:
465465
m_LightCookieSize: {x: 1, y: 1}
466466
m_LightCookieOffset: {x: 0, y: 0}
467467
m_SoftShadowQuality: 0
468+
--- !u!1001 &387878127
469+
PrefabInstance:
470+
m_ObjectHideFlags: 0
471+
serializedVersion: 2
472+
m_Modification:
473+
serializedVersion: 3
474+
m_TransformParent: {fileID: 0}
475+
m_Modifications:
476+
- target: {fileID: 4141237635811601714, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
477+
propertyPath: m_Name
478+
value: VivoxManager
479+
objectReference: {fileID: 0}
480+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
481+
propertyPath: m_LocalPosition.x
482+
value: 0
483+
objectReference: {fileID: 0}
484+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
485+
propertyPath: m_LocalPosition.y
486+
value: 0
487+
objectReference: {fileID: 0}
488+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
489+
propertyPath: m_LocalPosition.z
490+
value: 0
491+
objectReference: {fileID: 0}
492+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
493+
propertyPath: m_LocalRotation.w
494+
value: 1
495+
objectReference: {fileID: 0}
496+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
497+
propertyPath: m_LocalRotation.x
498+
value: 0
499+
objectReference: {fileID: 0}
500+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
501+
propertyPath: m_LocalRotation.y
502+
value: 0
503+
objectReference: {fileID: 0}
504+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
505+
propertyPath: m_LocalRotation.z
506+
value: 0
507+
objectReference: {fileID: 0}
508+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
509+
propertyPath: m_LocalEulerAnglesHint.x
510+
value: 0
511+
objectReference: {fileID: 0}
512+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
513+
propertyPath: m_LocalEulerAnglesHint.y
514+
value: 0
515+
objectReference: {fileID: 0}
516+
- target: {fileID: 7448202836938688200, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
517+
propertyPath: m_LocalEulerAnglesHint.z
518+
value: 0
519+
objectReference: {fileID: 0}
520+
m_RemovedComponents: []
521+
m_RemovedGameObjects: []
522+
m_AddedGameObjects: []
523+
m_AddedComponents: []
524+
m_SourcePrefab: {fileID: 100100000, guid: 53316d28950de8e4494bc48f320e09f6, type: 3}
468525
--- !u!1001 &406782382
469526
PrefabInstance:
470527
m_ObjectHideFlags: 0
@@ -291126,3 +291183,4 @@ SceneRoots:
291126291183
- {fileID: 735923504}
291127291184
- {fileID: 8089728398451373915}
291128291185
- {fileID: 2053309536}
291186+
- {fileID: 387878127}

Basic/DistributedAuthoritySocialHub/Assets/Scripts/GameManagement/GameplayEventHandler.cs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ static class GameplayEventHandler
1313
internal static event Action<string, string> OnStartButtonPressed;
1414
internal static event Action OnReturnToMainMenuButtonPressed;
1515
internal static event Action OnQuitGameButtonPressed;
16-
internal static event Action<Task> OnConnectToSessionCompleted;
16+
internal static event Action<Task, string> OnConnectToSessionCompleted;
1717
internal static event Action OnExitedSession;
18+
internal static event Action<string, string, bool> OnTextMessageReceived;
19+
internal static event Action<string> OnSendTextMessage;
20+
internal static event Action<bool> OnBlockPlayerControls;
21+
internal static event Action<bool> OnChatIsReady;
1822

1923
internal static void NetworkObjectDespawned(NetworkObject networkObject)
2024
{
@@ -41,9 +45,9 @@ internal static void QuitGamePressed()
4145
OnQuitGameButtonPressed?.Invoke();
4246
}
4347

44-
internal static void ConnectToSessionComplete(Task task)
48+
internal static void ConnectToSessionComplete(Task task, string sessionName)
4549
{
46-
OnConnectToSessionCompleted?.Invoke(task);
50+
OnConnectToSessionCompleted?.Invoke(task, sessionName);
4751
}
4852

4953
internal static void ExitedSession()
@@ -60,5 +64,25 @@ internal static void LoadInGameScene()
6064
{
6165
SceneManager.LoadScene("HubScene_TownMarket");
6266
}
67+
68+
internal static void ProcessTextMessageReceived(string senderName, string message, bool fromSelf)
69+
{
70+
OnTextMessageReceived?.Invoke(senderName, message, fromSelf);
71+
}
72+
73+
internal static void SendTextMessage(string message)
74+
{
75+
OnSendTextMessage?.Invoke(message);
76+
}
77+
78+
public static void BlockPlayerControls(bool disable)
79+
{
80+
OnBlockPlayerControls?.Invoke(disable);
81+
}
82+
83+
public static void SetTextChatReady(bool enabled)
84+
{
85+
OnChatIsReady?.Invoke(enabled);
86+
}
6387
}
6488
}

Basic/DistributedAuthoritySocialHub/Assets/Scripts/GameManagement/MainMenuHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void OnDestroy()
1515
GameplayEventHandler.OnConnectToSessionCompleted -= OnConnectToSessionCompleted;
1616
}
1717

18-
void OnConnectToSessionCompleted(Task task)
18+
void OnConnectToSessionCompleted(Task task, string sessionName)
1919
{
2020
if (task.IsCompletedSuccessfully)
2121
{

Basic/DistributedAuthoritySocialHub/Assets/Scripts/Player/AvatarTransform.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using Unity.Collections;
3+
using Unity.Multiplayer.Samples.SocialHub.GameManagement;
34
using Unity.Multiplayer.Samples.SocialHub.Gameplay;
45
using UnityEngine;
56
using Unity.Multiplayer.Samples.SocialHub.Input;
@@ -71,6 +72,8 @@ public override void OnNetworkSpawn()
7172
Debug.LogError("CameraControl not found on the Main Camera or Main Camera is missing.");
7273
}
7374

75+
GameplayEventHandler.OnBlockPlayerControls += OnBlockPlayerControls;
76+
7477
base.OnNetworkSpawn();
7578
}
7679

@@ -91,6 +94,7 @@ public override void OnNetworkDespawn()
9194
cameraControl.SetTransform(null);
9295
}
9396

97+
GameplayEventHandler.OnBlockPlayerControls -= OnBlockPlayerControls;
9498
m_TopUIController?.RemovePlayer(gameObject);
9599
}
96100

@@ -122,6 +126,11 @@ void OnPlayerNameChanged(FixedString32Bytes previousValue, FixedString32Bytes ne
122126
m_TopUIController.AddPlayer(gameObject, newValue.Value);
123127
}
124128

129+
void OnBlockPlayerControls(bool blockInput)
130+
{
131+
m_PlayerInput.enabled = !blockInput;
132+
}
133+
125134
public void NetworkUpdate(NetworkUpdateStage updateStage)
126135
{
127136
switch (updateStage)

0 commit comments

Comments
 (0)