Skip to content

Commit

Permalink
Ajuste do sistema de controle
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasVinicius314 committed Sep 16, 2022
1 parent b0b680f commit dae42ec
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Assets/Prefabs/Canvas.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Esconder controles flutuantes
m_Text: Ocultar controles flutuantes
--- !u!1 &2932101238255713229
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1469,7 +1469,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 2932101238483661020}
m_HandleRect: {fileID: 2932101238483661021}
m_Direction: 2
m_Value: 1
m_Value: 0
m_Size: 1
m_NumberOfSteps: 0
m_OnValueChanged:
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/GameManagerScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void DisableGamepad()

gamepadGroup.SetActive(false);

LocalPrefs.SetGamepadEnabled(false);
LocalPrefs.SetGamepadDisabled(true);
}

public void DisableMenu()
Expand All @@ -72,7 +72,7 @@ public void EnableGamepad()

gamepadGroup.SetActive(true);

LocalPrefs.SetGamepadEnabled(true);
LocalPrefs.SetGamepadDisabled(false);
}

public void EnableMenu()
Expand Down
10 changes: 5 additions & 5 deletions Assets/Scripts/MenuScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class MenuScript : MonoBehaviour
{
Toggle? gamepadDisabledToggle;

void SetGamepadEnabled(bool value, Toggle gamepadDisabledToggle)
void SetGamepadDisabled(bool value, Toggle gamepadDisabledToggle)
{
gamepadDisabledToggle.isOn = value;

Expand All @@ -30,17 +30,17 @@ void Awake()

void Start()
{
var gamepadEnabled = LocalPrefs.GetGamepadEnabled();
var gamepadDisabled = LocalPrefs.GetGamepadDisabled();

if (gamepadDisabledToggle != null)
{
SetGamepadEnabled(gamepadEnabled, gamepadDisabledToggle);
SetGamepadDisabled(gamepadDisabled, gamepadDisabledToggle);

gamepadDisabledToggle.onValueChanged.AddListener((value) =>
{
SetGamepadEnabled(value, gamepadDisabledToggle);
SetGamepadDisabled(value, gamepadDisabledToggle);

LocalPrefs.SetGamepadEnabled(value);
LocalPrefs.SetGamepadDisabled(value);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/PlayerScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void HandleConfigInitialization()
{
GameManagerScript.instance.DisableMenu();

if (!LocalPrefs.GetGamepadEnabled())
if (LocalPrefs.GetGamepadDisabled())
{
GameManagerScript.instance.DisableGamepad();
}
Expand Down
8 changes: 4 additions & 4 deletions Assets/Scripts/Utils/LocalPrefs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ public enum LocalPrefKeys

public static class LocalPrefs
{
public static bool GetGamepadEnabled()
public static bool GetGamepadDisabled()
{
return PlayerPrefs.GetInt(
LocalPrefKeys.gamepadDisabled.ToString()
) == 0;
) == 1;
}

public static void SetGamepadEnabled(bool gamepadEnabled)
public static void SetGamepadDisabled(bool gamepadDisabled)
{
PlayerPrefs.SetInt(
LocalPrefKeys.gamepadDisabled.ToString(),
gamepadEnabled ? 0 : 1
gamepadDisabled ? 1 : 0
);
}
}

0 comments on commit dae42ec

Please sign in to comment.