private void OnPressBallSkinPreview(BallSkinPreview newSelectedPrevieweview) { selectedPreview.ToggleSelection(false); newSelectedPrevieweview.ToggleSelection(true); selectedPreview = newSelectedPrevieweview; Events.chooseBallSkinEvent?.Invoke(newSelectedPrevieweview.Id); }
private void CreatePreviews() { foreach (CollectibleSprite collectibleSprite in BallSkinData.ballSkinsCollection.sprites) { BallSkinPreview preview = Instantiate(previewPrefab); preview.transform.SetParent(previewsContainer, false); preview.Initialize(collectibleSprite, OnPressBallSkinPreview); if (BallSkinData.currentBallSkinId == collectibleSprite.id) { preview.ToggleSelection(true); selectedPreview = preview; } } }