Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple Game Settings #1281 #1431

Merged
merged 3 commits into from
Apr 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add UserInterfaceSettings script and fix BandwidthView not showing
Sjerty committed Mar 15, 2024
commit 48313c615543a7de2c08cf814e8a74b5ea1ba110
20 changes: 18 additions & 2 deletions Assets/Content/Scenes/Boot.unity
Original file line number Diff line number Diff line change
@@ -1333,6 +1333,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 3c05cbdf20b74dacbc886660386d2919, type: 3}
m_Name:
m_EditorClassIdentifier:
NetworkType: 0
ServerAddress:
Port: 0
--- !u!1 &1966326253
GameObject:
m_ObjectHideFlags: 0
@@ -1438,8 +1441,8 @@ MonoBehaviour:
m_Calls: []
m_text: ckey - application mode
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 62e6adf63482d6f42aee1f313095799e, type: 2}
m_sharedMaterial: {fileID: -5529144078996397610, guid: 62e6adf63482d6f42aee1f313095799e, type: 2}
m_fontAsset: {fileID: 11400000, guid: ffc81b96d71d7544580ef63e2d508f02, type: 2}
m_sharedMaterial: {fileID: 8572051279392437555, guid: ffc81b96d71d7544580ef63e2d508f02, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
@@ -1536,6 +1539,7 @@ GameObject:
m_Component:
- component: {fileID: 2109038012}
- component: {fileID: 2109038010}
- component: {fileID: 2109038013}
m_Layer: 0
m_Name: BandwithDisplayDebug
m_TagString: Untagged
@@ -1574,3 +1578,15 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2109038013
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2109038009}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 748528fe61fbac44bb380645d676726c, type: 3}
m_Name:
m_EditorClassIdentifier:
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ namespace SS3D.Networking.Debug
/// <summary>
/// Overrides FishNets BandwidthDisplay class to implement a way to disable it using ScriptableSettings.
/// </summary>
public class BandwitdhView : BandwidthDisplay
public class BandwidthView : BandwidthDisplay
{
private void Awake()
{
4 changes: 3 additions & 1 deletion Assets/Scripts/SS3D/UI/SS3D.UI.asmdef
Original file line number Diff line number Diff line change
@@ -9,7 +9,9 @@
"GUID:6aabbee860c32c64d9bbd52d0704ed2c",
"GUID:d2bbca7254de5e746857b04cfb560876",
"GUID:b763ff73a93a62c4ea128e32ed2cd0d6",
"GUID:2aa873da5672f9c418c3d5556aaa7ca8"
"GUID:2aa873da5672f9c418c3d5556aaa7ca8",
"GUID:493bb11add906094faa30425cab7ce2e",
"GUID:7c88a4a7926ee5145ad2dfa06f454c67"
],
"includePlatforms": [],
"excludePlatforms": [],
38 changes: 38 additions & 0 deletions Assets/Scripts/SS3D/UI/Settings/UserInterfaceSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using UnityEngine;
using UnityEngine.Assertions;
using Coimbra;
using SS3D.Networking.Debug;
using SS3D.Networking.Settings;

namespace SS3D.UI.Settings
{
public class UserInterfaceSettings : MonoBehaviour
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why this is needed, we already have a ScriptableSettings to add the bandwidth display. I also don't agree at all with having stamina and bandwidth be in the same script in any form, they are not related and if we want to add more stuff it will quickly become a gigantic class.

I really don't see the need for this class at all

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A user interface settings class would have more global settings, such as global scale, theme.

{
[SerializeField]
private GameObject _staminaBar;
private BandwidthView _bandwidthView;

private bool _enableNetworkBandwidthUsageStats;

private void Awake()
{
Assert.IsNotNull(_staminaBar);
_bandwidthView = FindObjectOfType<BandwidthView>();
_enableNetworkBandwidthUsageStats =
ScriptableSettings.GetOrFind<NetworkSettings>().EnableNetworkBandwidthUsageStats;
}

public void ToogleStaminaBar(bool isActive)
{
_staminaBar.SetActive(isActive);
}

public void ToogleNetworkTrafficInfo(bool isActive)
{
if (_enableNetworkBandwidthUsageStats)
{
_bandwidthView.gameObject.SetActive(isActive);
}
}
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/SS3D/UI/Settings/UserInterfaceSettings.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.