AwesomeRunner/Assets/Scripts/Skin/PlayerSkinManager.cs
2025-02-10 18:53:36 +01:00

26 lines
764 B
C#

using UnityEngine;
public class PlayerSkinManager : MonoBehaviour
{
public SkinnedMeshRenderer[] bodyParts; // Liste des renderers
public Material[] skins; // Liste des matériaux (à remplir dans l'Inspector)
public string playerId; // Identifiant unique du joueur
void Start()
{
// Charger le skin sélectionné pour ce joueur spécifique
int selectedSkin = PlayerPrefs.GetInt($"SelectedSkin_{playerId}", 0);
ApplySkin(selectedSkin);
}
public void ApplySkin(int index)
{
if (index >= 0 && index < skins.Length)
{
foreach (var part in bodyParts) // Appliquer à chaque partie du corps
{
part.material = skins[index];
}
}
}
}