Исправление баги с обнулением выбора игрока при возвращении в меню

This commit is contained in:
Vladislav Likhenko 2024-08-12 14:49:46 +03:00
parent 95532a1839
commit 149bb7fa70
5 changed files with 47 additions and 6 deletions

View File

@ -32,7 +32,7 @@ public class SelectCarPlayerScript : MonoBehaviour
_IndexCar = (_IndexCar == _Cars.Count) ? 0 : _IndexCar; _IndexCar = (_IndexCar == _Cars.Count) ? 0 : _IndexCar;
_Cars[_IndexCar].SetActive(true); _Cars[_IndexCar].SetActive(true);
StaticDataMap.CarPlayers[_IndexPlayer] = _Cars[_IndexCar].name; StaticDataMap.CarPlayers[_IndexPlayer] = _Cars[_IndexCar].name;
Debug.Log($"{StaticDataMap.CarPlayers[_IndexPlayer]}"); //Debug.Log($"{StaticDataMap.CarPlayers[_IndexPlayer]}");
} }
public void SelectPrevious() public void SelectPrevious()
@ -42,6 +42,6 @@ public class SelectCarPlayerScript : MonoBehaviour
_IndexCar = (_IndexCar == -1) ? _Cars.Count - 1 : _IndexCar; _IndexCar = (_IndexCar == -1) ? _Cars.Count - 1 : _IndexCar;
_Cars[_IndexCar].SetActive(true); _Cars[_IndexCar].SetActive(true);
StaticDataMap.CarPlayers[_IndexPlayer] = _Cars[_IndexCar].name; StaticDataMap.CarPlayers[_IndexPlayer] = _Cars[_IndexCar].name;
Debug.Log($"{StaticDataMap.CarPlayers[_IndexPlayer]}"); //Debug.Log($"{StaticDataMap.CarPlayers[_IndexPlayer]}");
} }
} }

View File

@ -18,10 +18,10 @@ public class StartInfoSelectedScript : MonoBehaviour
private void Awake() private void Awake()
{ {
StaticDataMap.SelectedMap ??= _MapImages[0].name; StaticDataMap.SelectedMap ??= _MapImages[0].name;
StaticDataMap.Time = "Äåíü"; StaticDataMap.Time ??= "Äåíü";
StaticDataMap.NumPlayer = 1; StaticDataMap.NumPlayer ??= 1;
StaticDataMap.CarPlayers[0] = _CarsFirstPlayer[0].name; StaticDataMap.CarPlayers[0] ??= _CarsFirstPlayer[0].name;
StaticDataMap.CarPlayers[1] = _CarsSecondPlayer[0].name; StaticDataMap.CarPlayers[1] ??= _CarsSecondPlayer[0].name;
} }
private void OnEnable() private void OnEnable()

30
Assets/TestScript.cs Normal file
View File

@ -0,0 +1,30 @@
using UnityEngine;
public class TestScript : MonoBehaviour
{
void Awake()
{
if (StaticDataMap.SelectedMap == null)
{
Debug.Log("êàðòà íå óêàçàíà");
}
if (StaticDataMap.Time == null)
{
Debug.Log("Âðåìÿ íå óêàçàíî");
}
if (StaticDataMap.NumPlayer == null)
{
Debug.Log("Èãðîêè íå óêàçàíû");
StaticDataMap.NumPlayer = 123;
Debug.Log(StaticDataMap.NumPlayer);
}
if (StaticDataMap.CarPlayers[0] == null)
{
Debug.Log("Ïåðâûé èãðîê íå óêàçàí");
}
if (StaticDataMap.CarPlayers[1] == null)
{
Debug.Log("Âòîðîé èãðîê íå óêàçàí");
}
}
}

11
Assets/TestScript.cs.meta Normal file
View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bf9493dadb5d98f40900562c9fc29991
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: