diff --git a/Assets/Prefabs/Rig.prefab b/Assets/Prefabs/Rig.prefab index 82cf1185..803ee58d 100644 --- a/Assets/Prefabs/Rig.prefab +++ b/Assets/Prefabs/Rig.prefab @@ -21,23 +21,23 @@ PrefabInstance: - target: {fileID: 2723252326716659909, guid: f871c3b28fd786d4f820bea343f67979, type: 3} propertyPath: m_AnchorMax.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 2723252326716659909, guid: f871c3b28fd786d4f820bea343f67979, - type: 3} - propertyPath: m_AnchorMin.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 2723252326716659909, guid: f871c3b28fd786d4f820bea343f67979, - type: 3} - propertyPath: m_SizeDelta.x value: 0 objectReference: {fileID: 0} - target: {fileID: 2723252326716659909, guid: f871c3b28fd786d4f820bea343f67979, type: 3} - propertyPath: m_SizeDelta.y + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2723252326716659909, guid: f871c3b28fd786d4f820bea343f67979, + type: 3} + propertyPath: m_SizeDelta.x value: 148 objectReference: {fileID: 0} + - target: {fileID: 2723252326716659909, guid: f871c3b28fd786d4f820bea343f67979, + type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 2723252326716659909, guid: f871c3b28fd786d4f820bea343f67979, type: 3} propertyPath: m_AnchoredPosition.x @@ -46,7 +46,7 @@ PrefabInstance: - target: {fileID: 2723252326716659909, guid: f871c3b28fd786d4f820bea343f67979, type: 3} propertyPath: m_AnchoredPosition.y - value: -280 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3680965801110432182, guid: f871c3b28fd786d4f820bea343f67979, type: 3} @@ -71,23 +71,23 @@ PrefabInstance: - target: {fileID: 6236588919629483555, guid: f871c3b28fd786d4f820bea343f67979, type: 3} propertyPath: m_AnchorMax.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 6236588919629483555, guid: f871c3b28fd786d4f820bea343f67979, - type: 3} - propertyPath: m_AnchorMin.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 6236588919629483555, guid: f871c3b28fd786d4f820bea343f67979, - type: 3} - propertyPath: m_SizeDelta.x value: 0 objectReference: {fileID: 0} - target: {fileID: 6236588919629483555, guid: f871c3b28fd786d4f820bea343f67979, type: 3} - propertyPath: m_SizeDelta.y + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6236588919629483555, guid: f871c3b28fd786d4f820bea343f67979, + type: 3} + propertyPath: m_SizeDelta.x value: 148 objectReference: {fileID: 0} + - target: {fileID: 6236588919629483555, guid: f871c3b28fd786d4f820bea343f67979, + type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 6236588919629483555, guid: f871c3b28fd786d4f820bea343f67979, type: 3} propertyPath: m_AnchoredPosition.x @@ -96,28 +96,28 @@ PrefabInstance: - target: {fileID: 6236588919629483555, guid: f871c3b28fd786d4f820bea343f67979, type: 3} propertyPath: m_AnchoredPosition.y - value: -280 - objectReference: {fileID: 0} - - target: {fileID: 6353877099413377020, guid: f871c3b28fd786d4f820bea343f67979, - type: 3} - propertyPath: m_AnchorMax.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 6353877099413377020, guid: f871c3b28fd786d4f820bea343f67979, - type: 3} - propertyPath: m_AnchorMin.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 6353877099413377020, guid: f871c3b28fd786d4f820bea343f67979, - type: 3} - propertyPath: m_SizeDelta.x value: 0 objectReference: {fileID: 0} - target: {fileID: 6353877099413377020, guid: f871c3b28fd786d4f820bea343f67979, type: 3} - propertyPath: m_SizeDelta.y + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6353877099413377020, guid: f871c3b28fd786d4f820bea343f67979, + type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6353877099413377020, guid: f871c3b28fd786d4f820bea343f67979, + type: 3} + propertyPath: m_SizeDelta.x value: 148 objectReference: {fileID: 0} + - target: {fileID: 6353877099413377020, guid: f871c3b28fd786d4f820bea343f67979, + type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 6353877099413377020, guid: f871c3b28fd786d4f820bea343f67979, type: 3} propertyPath: m_AnchoredPosition.x @@ -126,28 +126,28 @@ PrefabInstance: - target: {fileID: 6353877099413377020, guid: f871c3b28fd786d4f820bea343f67979, type: 3} propertyPath: m_AnchoredPosition.y - value: -206 - objectReference: {fileID: 0} - - target: {fileID: 6413800453266084155, guid: f871c3b28fd786d4f820bea343f67979, - type: 3} - propertyPath: m_AnchorMax.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 6413800453266084155, guid: f871c3b28fd786d4f820bea343f67979, - type: 3} - propertyPath: m_AnchorMin.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 6413800453266084155, guid: f871c3b28fd786d4f820bea343f67979, - type: 3} - propertyPath: m_SizeDelta.x value: 0 objectReference: {fileID: 0} - target: {fileID: 6413800453266084155, guid: f871c3b28fd786d4f820bea343f67979, type: 3} - propertyPath: m_SizeDelta.y + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6413800453266084155, guid: f871c3b28fd786d4f820bea343f67979, + type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6413800453266084155, guid: f871c3b28fd786d4f820bea343f67979, + type: 3} + propertyPath: m_SizeDelta.x value: 148 objectReference: {fileID: 0} + - target: {fileID: 6413800453266084155, guid: f871c3b28fd786d4f820bea343f67979, + type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 6413800453266084155, guid: f871c3b28fd786d4f820bea343f67979, type: 3} propertyPath: m_AnchoredPosition.x @@ -156,7 +156,7 @@ PrefabInstance: - target: {fileID: 6413800453266084155, guid: f871c3b28fd786d4f820bea343f67979, type: 3} propertyPath: m_AnchoredPosition.y - value: -280 + value: 0 objectReference: {fileID: 0} - target: {fileID: 7749079862415865764, guid: f871c3b28fd786d4f820bea343f67979, type: 3} @@ -622,7 +622,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} m_Name: m_EditorClassIdentifier: - GlobalObjectIdHash: 3394388680 + GlobalObjectIdHash: 918221477 InScenePlacedSourceGlobalObjectIdHash: 0 AlwaysReplicateAsRoot: 0 SynchronizeTransform: 1 diff --git a/Assets/Prefabs/UI/LobbyMenu/PlayerItem.prefab b/Assets/Prefabs/UI/LobbyMenu/PlayerItem.prefab index e509d652..dc78b694 100644 --- a/Assets/Prefabs/UI/LobbyMenu/PlayerItem.prefab +++ b/Assets/Prefabs/UI/LobbyMenu/PlayerItem.prefab @@ -113,6 +113,7 @@ MonoBehaviour: playerImage: {fileID: 8099569868075258247} emptyGroup: {fileID: 4280662165316134992} activeGroup: {fileID: 2984876657522624788} + defaultPlayerImage: {fileID: 21300000, guid: 695bf1a0f9b004b57b57a6b3f78e4322, type: 3} --- !u!1 &214368010157340983 GameObject: m_ObjectHideFlags: 0 @@ -138,7 +139,7 @@ RectTransform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 214368010157340983} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0.0001490116} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -147,8 +148,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0.000076293945, y: 0} - m_SizeDelta: {x: -20, y: -20} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: -22, y: -22} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &2939737273055999062 MonoBehaviour: diff --git a/Assets/Scenes/Lobby.unity b/Assets/Scenes/Lobby.unity index 645680d6..8f2f9d41 100644 --- a/Assets/Scenes/Lobby.unity +++ b/Assets/Scenes/Lobby.unity @@ -1240,7 +1240,7 @@ PrefabInstance: - target: {fileID: 1823291527766241088, guid: 8c558b450b0d54df8b6a2608aa29a87b, type: 3} propertyPath: m_Name - value: Button_Rectangle_01_Convex_Red + value: LeaveButton objectReference: {fileID: 0} - target: {fileID: 1823291527766241091, guid: 8c558b450b0d54df8b6a2608aa29a87b, type: 3} @@ -2810,6 +2810,37 @@ Transform: type: 3} m_PrefabInstance: {fileID: 212601291} m_PrefabAsset: {fileID: 0} +--- !u!1 &216372457 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 216372458} + m_Layer: 0 + m_Name: Character_Sample_04 (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &216372458 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 216372457} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &217767396 PrefabInstance: m_ObjectHideFlags: 0 @@ -4369,7 +4400,7 @@ PrefabInstance: - target: {fileID: 3163847993249717490, guid: 693918f5252cc9543ad4901c66a265ed, type: 3} propertyPath: m_AnchorMax.y - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3163847993249717490, guid: 693918f5252cc9543ad4901c66a265ed, type: 3} @@ -4379,7 +4410,7 @@ PrefabInstance: - target: {fileID: 3163847993249717490, guid: 693918f5252cc9543ad4901c66a265ed, type: 3} propertyPath: m_AnchorMin.y - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3163847993249717490, guid: 693918f5252cc9543ad4901c66a265ed, type: 3} @@ -4444,12 +4475,12 @@ PrefabInstance: - target: {fileID: 3163847993249717490, guid: 693918f5252cc9543ad4901c66a265ed, type: 3} propertyPath: m_AnchoredPosition.x - value: 478 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3163847993249717490, guid: 693918f5252cc9543ad4901c66a265ed, type: 3} propertyPath: m_AnchoredPosition.y - value: -329 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3163847993249717490, guid: 693918f5252cc9543ad4901c66a265ed, type: 3} @@ -4476,6 +4507,37 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 693918f5252cc9543ad4901c66a265ed, type: 3} +--- !u!1 &310335279 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 310335280} + m_Layer: 0 + m_Name: Character_Sample_04 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &310335280 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 310335279} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &313084521 PrefabInstance: m_ObjectHideFlags: 0 @@ -7726,7 +7788,7 @@ PrefabInstance: - target: {fileID: 8218563352662433355, guid: 0b2f49667301602429912df646dccb54, type: 3} propertyPath: m_AnchorMax.y - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 8218563352662433355, guid: 0b2f49667301602429912df646dccb54, type: 3} @@ -7736,7 +7798,7 @@ PrefabInstance: - target: {fileID: 8218563352662433355, guid: 0b2f49667301602429912df646dccb54, type: 3} propertyPath: m_AnchorMin.y - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 8218563352662433355, guid: 0b2f49667301602429912df646dccb54, type: 3} @@ -7786,7 +7848,7 @@ PrefabInstance: - target: {fileID: 8218563352662433355, guid: 0b2f49667301602429912df646dccb54, type: 3} propertyPath: m_AnchoredPosition.x - value: 200 + value: 0 objectReference: {fileID: 0} - target: {fileID: 8218563352662433355, guid: 0b2f49667301602429912df646dccb54, type: 3} @@ -15328,7 +15390,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &1142897203 RectTransform: m_ObjectHideFlags: 0 @@ -17131,6 +17193,18 @@ Transform: type: 3} m_PrefabInstance: {fileID: 1250291034} m_PrefabAsset: {fileID: 0} +--- !u!114 &1253047056 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 1823291527766241090, guid: 8c558b450b0d54df8b6a2608aa29a87b, + type: 3} + m_PrefabInstance: {fileID: 114580583} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1001 &1255715122 PrefabInstance: m_ObjectHideFlags: 0 @@ -20080,7 +20154,7 @@ PrefabInstance: - target: {fileID: 5164178704720697696, guid: 24e15d0d27d6f4c678cbb5bfb748e0d6, type: 3} propertyPath: m_AnchorMax.y - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 5164178704720697696, guid: 24e15d0d27d6f4c678cbb5bfb748e0d6, type: 3} @@ -20090,7 +20164,7 @@ PrefabInstance: - target: {fileID: 5164178704720697696, guid: 24e15d0d27d6f4c678cbb5bfb748e0d6, type: 3} propertyPath: m_AnchorMin.y - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 5164178704720697696, guid: 24e15d0d27d6f4c678cbb5bfb748e0d6, type: 3} @@ -20140,12 +20214,12 @@ PrefabInstance: - target: {fileID: 5164178704720697696, guid: 24e15d0d27d6f4c678cbb5bfb748e0d6, type: 3} propertyPath: m_AnchoredPosition.x - value: 478 + value: 0 objectReference: {fileID: 0} - target: {fileID: 5164178704720697696, guid: 24e15d0d27d6f4c678cbb5bfb748e0d6, type: 3} propertyPath: m_AnchoredPosition.y - value: -497.7 + value: 0 objectReference: {fileID: 0} - target: {fileID: 5164178704720697696, guid: 24e15d0d27d6f4c678cbb5bfb748e0d6, type: 3} @@ -20717,6 +20791,18 @@ RectTransform: type: 3} m_PrefabInstance: {fileID: 538604535} m_PrefabAsset: {fileID: 0} +--- !u!114 &1474707919 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 8218563352662433352, guid: 0b2f49667301602429912df646dccb54, + type: 3} + m_PrefabInstance: {fileID: 538604535} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2da0c512f12947e489f739169773d7ca, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1001 &1481416243 PrefabInstance: m_ObjectHideFlags: 0 @@ -20803,7 +20889,7 @@ PrefabInstance: - target: {fileID: 5164178704720697696, guid: 24e15d0d27d6f4c678cbb5bfb748e0d6, type: 3} propertyPath: m_AnchorMax.y - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 5164178704720697696, guid: 24e15d0d27d6f4c678cbb5bfb748e0d6, type: 3} @@ -20813,7 +20899,7 @@ PrefabInstance: - target: {fileID: 5164178704720697696, guid: 24e15d0d27d6f4c678cbb5bfb748e0d6, type: 3} propertyPath: m_AnchorMin.y - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 5164178704720697696, guid: 24e15d0d27d6f4c678cbb5bfb748e0d6, type: 3} @@ -20863,12 +20949,12 @@ PrefabInstance: - target: {fileID: 5164178704720697696, guid: 24e15d0d27d6f4c678cbb5bfb748e0d6, type: 3} propertyPath: m_AnchoredPosition.x - value: 535 + value: 0 objectReference: {fileID: 0} - target: {fileID: 5164178704720697696, guid: 24e15d0d27d6f4c678cbb5bfb748e0d6, type: 3} propertyPath: m_AnchoredPosition.y - value: -50 + value: 0 objectReference: {fileID: 0} - target: {fileID: 5164178704720697696, guid: 24e15d0d27d6f4c678cbb5bfb748e0d6, type: 3} @@ -26979,7 +27065,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} m_AnchoredPosition: {x: 478, y: -160.3} - m_SizeDelta: {x: 635, y: 100} + m_SizeDelta: {x: 635, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1870248540 MonoBehaviour: @@ -30995,16 +31081,16 @@ MonoBehaviour: gameManager: {fileID: 0} canvas: {fileID: 0} joinOrHost: {fileID: 1142897202} - roomCodeInput: {fileID: 0} + roomCodeInput: {fileID: 1474707919} joinButton: {fileID: 1705793166} hostButton: {fileID: 1173017140} - connected: {fileID: 711782649} + connected: {fileID: 1350483113} playerItems: - {fileID: 759219683049267180} - {fileID: 959645604} - {fileID: 204172856} - {fileID: 2064238308} - leaveButton: {fileID: 0} + leaveButton: {fileID: 1253047056} --- !u!1001 &2097871276 PrefabInstance: m_ObjectHideFlags: 0 @@ -35294,3 +35380,5 @@ SceneRoots: - {fileID: 2770940432321735806} - {fileID: 2097484082} - {fileID: 856515705} + - {fileID: 310335280} + - {fileID: 216372458} diff --git a/Assets/Scripts/Data/PlayerInfo.cs b/Assets/Scripts/Data/PlayerInfo.cs index e147fc33..b55c9872 100644 --- a/Assets/Scripts/Data/PlayerInfo.cs +++ b/Assets/Scripts/Data/PlayerInfo.cs @@ -6,4 +6,5 @@ public struct PlayerInfo { public string Name; public Sprite Image; + public bool isLocalPlayer; } diff --git a/Assets/Scripts/Managers/GameManager.cs b/Assets/Scripts/Managers/GameManager.cs index 852e5f12..9dd9b4e6 100644 --- a/Assets/Scripts/Managers/GameManager.cs +++ b/Assets/Scripts/Managers/GameManager.cs @@ -5,6 +5,7 @@ using UnityEngine; using Zenject; using ParrelSync; using UnityEngine.Events; +using System.Collections.Generic; public class GameManager : NetworkBehaviour { @@ -27,10 +28,13 @@ public class GameManager : NetworkBehaviour [SerializeField] private bool autoConnectOrHost = true; - public bool IsMultiplayer => networkManager.IsHost || networkManager.IsClient; + public bool IsMultiplayer => networkManager.IsConnectedClient; + + public NetworkClient LocalClient => networkManager.LocalClient; public UnityEvent OnConnected; public UnityEvent OnDisconnected; + public UnityEvent> OnClientsChanged; private void Start() { @@ -78,11 +82,13 @@ public class GameManager : NetworkBehaviour private void OnClientStarted() { OnConnected?.Invoke(); + OnClientsChanged.Invoke(networkManager.ConnectedClientsList); } private void OnClientStopped(bool wasHost) { OnDisconnected?.Invoke(); + OnClientsChanged.Invoke(networkManager.ConnectedClientsList); } private void OnClientConnectedCallback(ulong clientId) @@ -93,6 +99,8 @@ public class GameManager : NetworkBehaviour { StartCoroutine(SwitchSoloMultiplayerRig(false)); } + + OnClientsChanged.Invoke(networkManager.ConnectedClientsList); } private IEnumerator SwitchSoloMultiplayerRig(bool toSolo) @@ -126,5 +134,7 @@ public class GameManager : NetworkBehaviour { StartCoroutine(SwitchSoloMultiplayerRig(true)); } + + OnClientsChanged.Invoke(networkManager.ConnectedClientsList); } } diff --git a/Assets/Scripts/UI/HandMenuUI.cs b/Assets/Scripts/UI/HandMenuUI.cs index 884057a7..ca824262 100644 --- a/Assets/Scripts/UI/HandMenuUI.cs +++ b/Assets/Scripts/UI/HandMenuUI.cs @@ -1,14 +1,13 @@ using HurricaneVR.Framework.ControllerInput; using HurricaneVR.Framework.Core.UI; using Sirenix.OdinInspector; -using System.Collections; -using System.Collections.Generic; using TMPro; +using Unity.Netcode; using UnityEngine; using UnityEngine.UI; using Zenject; -public class HandMenuUI : MonoBehaviour +public class HandMenuUI : NetworkBehaviour { [Inject] [ReadOnly] @@ -89,6 +88,14 @@ public class HandMenuUI : MonoBehaviour settingsButton.onClick.AddListener(() => SettingsClicked()); } + public override void OnNetworkSpawn() + { + base.OnNetworkSpawn(); + + // Player components need to be injected manualy again, because NetworkManager doesn't inject them. + gameObject.Inject(); + } + private void Update() { CheckInput(); diff --git a/Assets/Scripts/UI/LobbyMenuUI.cs b/Assets/Scripts/UI/LobbyMenuUI.cs index 608823aa..e4799edb 100644 --- a/Assets/Scripts/UI/LobbyMenuUI.cs +++ b/Assets/Scripts/UI/LobbyMenuUI.cs @@ -1,5 +1,6 @@ using HurricaneVR.Framework.Core.UI; using Sirenix.OdinInspector; +using System.Collections.Generic; using TMPro; using Unity.Netcode; using UnityEngine; @@ -51,6 +52,8 @@ public class LobbyMenuUI : MonoBehaviour private bool isConnected => gameManager.IsMultiplayer; + private IReadOnlyList networkClients = new List(); + private void Start() { if (uiInput == null) return; @@ -64,6 +67,12 @@ public class LobbyMenuUI : MonoBehaviour gameManager.OnConnected.AddListener(() => UpdateUI()); gameManager.OnDisconnected.AddListener(() => UpdateUI()); + gameManager.OnClientsChanged.AddListener((clients) => + { + networkClients = clients; + UpdateUI(); + }); + UpdateUI(); } @@ -73,6 +82,28 @@ public class LobbyMenuUI : MonoBehaviour connected.SetActive(isConnected); joinButton.interactable = true; hostButton.interactable = true; + + for (int i = 0; i < playerItems.Length; i++) + { + var item = playerItems[i]; + + if (i > networkClients.Count -1) + { + item.Setup(null); + } + else + { + var client = networkClients[i]; + + var playerInfo = new PlayerInfo() + { + Name = client.ClientId.ToString(), + isLocalPlayer = client.ClientId == gameManager.LocalClient.ClientId + }; + + item.Setup(playerInfo); + } + } } private void JoinClicked() diff --git a/Assets/Scripts/UI/PlayerItemUI.cs b/Assets/Scripts/UI/PlayerItemUI.cs index de022397..acd0667a 100644 --- a/Assets/Scripts/UI/PlayerItemUI.cs +++ b/Assets/Scripts/UI/PlayerItemUI.cs @@ -23,6 +23,9 @@ public class PlayerItemUI : MonoBehaviour [SerializeField] private PlayerInfo? playerInfo; + [SerializeField] + private Sprite defaultPlayerImage; + bool isEmpty => playerInfo == null; private void Start() @@ -44,7 +47,7 @@ public class PlayerItemUI : MonoBehaviour if (!isEmpty) { nameText.text = playerInfo?.Name; - playerImage.sprite = playerInfo?.Image; + playerImage.sprite = playerInfo?.Image ?? defaultPlayerImage; } } } diff --git a/Assets/Scripts/Utils/Injector.cs b/Assets/Scripts/Utils/Injector.cs new file mode 100644 index 00000000..a41fe7cc --- /dev/null +++ b/Assets/Scripts/Utils/Injector.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using static Zenject.ZenAutoInjecter; +using Zenject; +using ModestTree; + +public static class Injector +{ + static DiContainer LookupContainer(GameObject go, ContainerSources container) + { + if (container == ContainerSources.ProjectContext) + { + return ProjectContext.Instance.Container; + } + + if (container == ContainerSources.SceneContext) + { + return GetContainerForCurrentScene(go); + } + + Assert.IsEqual(container, ContainerSources.SearchHierarchy); + + var parentContext = go.transform.GetComponentInParent(); + + if (parentContext != null) + { + return parentContext.Container; + } + + return GetContainerForCurrentScene(go); + } + + static DiContainer GetContainerForCurrentScene(GameObject go) + { + return ProjectContext.Instance.Container + .Resolve() + .GetContainerForScene(go.scene); + } + + public static void Inject(this GameObject go, ContainerSources container = ContainerSources.SceneContext) + { + LookupContainer(go, container).InjectGameObject(go); + } +} diff --git a/Assets/Scripts/Utils/Injector.cs.meta b/Assets/Scripts/Utils/Injector.cs.meta new file mode 100644 index 00000000..bf175d61 --- /dev/null +++ b/Assets/Scripts/Utils/Injector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b7eb2cd65a9697441890fa5f41706bf7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: