Fix issues with icon loading
This commit is contained in:
@@ -24,7 +24,7 @@ public class Iconsmenu : MonoBehaviour
|
||||
[SerializeField] private GameObject previewBirdObject;
|
||||
[SerializeField] private ColorPanel iconColorPanel;
|
||||
[SerializeField] private ColorPanel overlayColorPanel;
|
||||
private Dictionary<string, Button> customIcons = new();
|
||||
private readonly Dictionary<string, Button> customIcons = new();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@@ -136,12 +136,11 @@ public class Iconsmenu : MonoBehaviour
|
||||
if (customIconData.Selected != null)
|
||||
foreach (var icon in customIconData.Purchased)
|
||||
{
|
||||
if (icon == customIconData.Selected) SelectCustomIcon(icon);
|
||||
if (icon == customIconData.Selected) SelectCustomIcon(icon, false);
|
||||
customIcons[icon].interactable = icon != customIconData.Selected;
|
||||
}
|
||||
|
||||
var objects = FindObjectsByType<WaitingForCustomIcon>(FindObjectsSortMode.None);
|
||||
if (objects.Length != 0) CustomIconLoader.Init(objects);
|
||||
RenderIcons();
|
||||
}
|
||||
|
||||
private void ToggleKit()
|
||||
@@ -217,14 +216,13 @@ public class Iconsmenu : MonoBehaviour
|
||||
else previewOverlay.sprite = Resources.Load<Sprite>("Icons/Overlays/overlay_" + overlayID);
|
||||
}
|
||||
|
||||
void SelectCustomIcon(string icon)
|
||||
void SelectCustomIcon(string icon, bool renderIcons = true)
|
||||
{
|
||||
var customData = BazookaManager.Instance.GetCustomBirdIconData();
|
||||
customData.Selected = icon;
|
||||
BazookaManager.Instance.SetCustomBirdIconData(customData);
|
||||
var waitingForCustomIcon = previewBird.AddComponent<WaitingForCustomIcon>();
|
||||
waitingForCustomIcon.ID = icon;
|
||||
CustomIconLoader.Init(new[] { waitingForCustomIcon });
|
||||
previewBird.AddComponent<WaitingForCustomIcon>().ID = icon;
|
||||
if (renderIcons) RenderIcons();
|
||||
previewBird.color = Color.white;
|
||||
previewOverlay.gameObject.SetActive(false);
|
||||
previewOverlay.sprite = null;
|
||||
@@ -239,4 +237,10 @@ public class Iconsmenu : MonoBehaviour
|
||||
{
|
||||
if (Keyboard.current.escapeKey.wasPressedThisFrame) await SceneManager.LoadSceneAsync("MainMenu");
|
||||
}
|
||||
|
||||
void RenderIcons()
|
||||
{
|
||||
var objects = FindObjectsByType<WaitingForCustomIcon>(FindObjectsSortMode.None);
|
||||
if (objects.Length != 0) CustomIconLoader.Init(objects);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user