diff --git a/Assets/Editor/MultiplayerManagerEditor.cs b/Assets/Editor/MultiplayerManagerEditor.cs index 386a0ae62..caa84ece8 100644 --- a/Assets/Editor/MultiplayerManagerEditor.cs +++ b/Assets/Editor/MultiplayerManagerEditor.cs @@ -82,8 +82,8 @@ public override void OnInspectorGUI() //Room Ownership string ownership = ""; - if (multiplayerManager != null && multiplayerManager.isUserRoomOwner) ownership = "Yes"; - else if (multiplayerManager != null && !multiplayerManager.isUserRoomOwner) ownership = "No"; + if (multiplayerManager != null && multiplayerManager.IsUserRoomOwner()) ownership = "Yes"; + else if (multiplayerManager != null && !multiplayerManager.IsUserRoomOwner()) ownership = "No"; else ownership = "Not Assigned"; EditorGUILayout.BeginHorizontal(); diff --git a/Assets/Prefabs/Panels/MultiplayerPanel.prefab b/Assets/Prefabs/Panels/MultiplayerPanel.prefab index eb77065a6..13272392a 100644 --- a/Assets/Prefabs/Panels/MultiplayerPanel.prefab +++ b/Assets/Prefabs/Panels/MultiplayerPanel.prefab @@ -115,6 +115,7 @@ MonoBehaviour: m_RoomNumber: {fileID: 9160963822650286723} m_Nickname: {fileID: 4888819335275065630} m_AlertsErrors: {fileID: 6437857310660163665} + m_RoomOwnership: {fileID: 0} references: version: 2 RefIds: [] @@ -975,7 +976,7 @@ Transform: m_GameObject: {fileID: 1032351299171828485} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0.617, y: -0.323, z: -0.042} + m_LocalPosition: {x: -0.617, y: -0.484, z: -0.042} m_LocalScale: {x: 0.33, y: 0.33, z: 0.33} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1165,7 +1166,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0.147, y: 0.035999954} + m_AnchoredPosition: {x: 0.147, y: 0.14799947} m_SizeDelta: {x: 1.104868, y: 1.4460607} m_Pivot: {x: 0.5, y: 0.5} --- !u!23 &3100622910448847287 @@ -2810,7 +2811,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0.466, y: -0.26} + m_AnchoredPosition: {x: 0.466, y: -0.14800048} m_SizeDelta: {x: 1.104868, y: 1.4460607} m_Pivot: {x: 0.5, y: 0.5} --- !u!23 &8677733851088090031 @@ -2981,7 +2982,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0.466, y: -0.5540001} + m_AnchoredPosition: {x: 0.466, y: -0.44200057} m_SizeDelta: {x: 1.104868, y: 1.4460607} m_Pivot: {x: 0.5, y: 0.5} --- !u!23 &2426349157769062346 @@ -3147,7 +3148,7 @@ Transform: m_GameObject: {fileID: 5899900900417153719} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.62, y: -0.323, z: -0.042} + m_LocalPosition: {x: 0.62, y: -0.48400003, z: -0.042} m_LocalScale: {x: 0.33, y: 0.33, z: 0.33} m_ConstrainProportionsScale: 0 m_Children: [] @@ -3527,6 +3528,7 @@ Transform: - {fileID: 4609499178869085959} - {fileID: 2677652558882906679} - {fileID: 8994233172856634412} + - {fileID: 3004064693637687833} - {fileID: 5239577752120043582} m_Father: {fileID: 415082} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -3765,7 +3767,7 @@ Transform: m_GameObject: {fileID: 6530187638887373145} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.208, y: -0.323, z: -0.042} + m_LocalPosition: {x: 0.208, y: -0.48400003, z: -0.042} m_LocalScale: {x: 0.33, y: 0.33, z: 0.33} m_ConstrainProportionsScale: 0 m_Children: [] @@ -3921,6 +3923,177 @@ MonoBehaviour: references: version: 2 RefIds: [] +--- !u!1 &6603807884407399516 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3004064693637687833} + - component: {fileID: 4811598343171871539} + - component: {fileID: 1415528830258304631} + m_Layer: 16 + m_Name: Room Ownership Status + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &3004064693637687833 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6603807884407399516} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -0.05} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 8346410928580794432} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0.147, y: -0.73} + m_SizeDelta: {x: 1.104868, y: 1.4460607} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!23 &4811598343171871539 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6603807884407399516} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2133298, guid: fce54057bad3d2d4cb3c36ee394be518, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!114 &1415528830258304631 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6603807884407399516} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9541d86e2fd84c1d9990edf0852d74ab, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: Room Owner + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: fce54057bad3d2d4cb3c36ee394be518, type: 2} + m_sharedMaterial: {fileID: 2133298, guid: fce54057bad3d2d4cb3c36ee394be518, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 1.5 + m_fontSizeBase: 1.5 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 1 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: -30 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 0 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: -0.31141979, y: -0.12023544, z: -0.1872099, w: 1.1764753} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + _SortingLayer: 0 + _SortingLayerID: 0 + _SortingOrder: 0 + m_hasFontAssetChanged: 0 + m_renderer: {fileID: 4811598343171871539} + m_maskType: 0 --- !u!1 &7101128147202961155 GameObject: m_ObjectHideFlags: 0 @@ -3950,7 +4123,7 @@ Transform: m_GameObject: {fileID: 7101128147202961155} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0.206, y: -0.323, z: -0.042} + m_LocalPosition: {x: -0.206, y: -0.48400003, z: -0.042} m_LocalScale: {x: 0.33, y: 0.33, z: 0.33} m_ConstrainProportionsScale: 0 m_Children: [] @@ -4135,7 +4308,7 @@ Transform: m_GameObject: {fileID: 7355810358076377629} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0.619, y: 0.09, z: -0.042} + m_LocalPosition: {x: -0.619, y: 0.20199952, z: -0.042} m_LocalScale: {x: 0.15, y: 0.15, z: 0.15} m_ConstrainProportionsScale: 0 m_Children: [] @@ -4506,7 +4679,7 @@ Transform: m_GameObject: {fileID: 7521510091458286424} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0.619, y: 0.384, z: -0.042} + m_LocalPosition: {x: -0.619, y: 0.496, z: -0.042} m_LocalScale: {x: 0.15, y: 0.15, z: 0.15} m_ConstrainProportionsScale: 0 m_Children: [] diff --git a/Assets/Scripts/GUI/MultiplayerPanel.cs b/Assets/Scripts/GUI/MultiplayerPanel.cs index 94f1d6918..2adc09f3c 100644 --- a/Assets/Scripts/GUI/MultiplayerPanel.cs +++ b/Assets/Scripts/GUI/MultiplayerPanel.cs @@ -27,6 +27,7 @@ public class MultiplayerPanel : BasePanel [SerializeField] private TextMeshPro m_RoomNumber; [SerializeField] private TextMeshPro m_Nickname; [SerializeField] private TextMeshPro m_AlertsErrors; + [SerializeField] private TextMeshPro m_RoomOwnership; public string RoomName { @@ -80,7 +81,11 @@ public void Awake() CheckIfRoomExist, }; - if (MultiplayerManager.m_Instance != null) MultiplayerManager.m_Instance.StateUpdated += OnStateUpdated; + if (MultiplayerManager.m_Instance != null) + { + MultiplayerManager.m_Instance.StateUpdated += OnStateUpdated; + MultiplayerManager.m_Instance.RoomOwnershipUpdated += OnRoomOwnershipUpdated; + } } @@ -165,10 +170,18 @@ private async void Disconnect() private void OnStateUpdated(ConnectionState newState) { + if (!m_State) return; m_State.text = "State: " + newState.ToString(); UpdateDisplay(); } + private void OnRoomOwnershipUpdated(bool isRoomOwner) + { + if (!m_RoomOwnership) return; + m_RoomOwnership.text = isRoomOwner ? "Room Owner" : "Not Room Owner"; + UpdateDisplay(); + } + private Tuple CheckAdvancedModeActive() { if (PanelManager.m_Instance != null) diff --git a/Assets/Scripts/Multiplayer/MultiplayerManager.cs b/Assets/Scripts/Multiplayer/MultiplayerManager.cs index a98d47399..78d7dc9da 100644 --- a/Assets/Scripts/Multiplayer/MultiplayerManager.cs +++ b/Assets/Scripts/Multiplayer/MultiplayerManager.cs @@ -54,6 +54,7 @@ public class MultiplayerManager : MonoBehaviour public Action playerLeft; public Action> roomDataRefreshed; public event Action StateUpdated; + public event Action RoomOwnershipUpdated; public event Action UserInfoStateUpdated; private List m_RoomData = new List(); @@ -94,7 +95,16 @@ public ConnectionUserInfo UserInfo [HideInInspector] public RoomCreateData data; - [HideInInspector] public bool isUserRoomOwner = false; //temporary public + private bool _isUserRoomOwner = false; + private bool isUserRoomOwner + { + get => _isUserRoomOwner; + set + { + _isUserRoomOwner = value; + RoomOwnershipUpdated?.Invoke(value); + } + } void Awake() { @@ -540,5 +550,10 @@ public bool CanLeaveRoom() { return State == ConnectionState.IN_ROOM; } + + public bool IsUserRoomOwner() + { + return isUserRoomOwner; + } } } diff --git a/Assets/Scripts/SketchControlsScript.cs b/Assets/Scripts/SketchControlsScript.cs index fea7b6796..3c9d47ab7 100644 --- a/Assets/Scripts/SketchControlsScript.cs +++ b/Assets/Scripts/SketchControlsScript.cs @@ -5001,9 +5001,9 @@ public bool IsCommandAvailable(GlobalCommands rEnum, int iParam = -1) // TODO: hide gallery view / publish if there are no saved sketches switch (rEnum) { - case GlobalCommands.Undo: + case GlobalCommands.Undo: return SketchMemoryScript.m_Instance.CanUndo() && !(MultiplayerManager.m_Instance.State == ConnectionState.IN_ROOM); - case GlobalCommands.Redo: + case GlobalCommands.Redo: return SketchMemoryScript.m_Instance.CanRedo() && !(MultiplayerManager.m_Instance.State == ConnectionState.IN_ROOM); case GlobalCommands.Save: bool canSave =