So i’m making a game with customization, and the player is a prefab that contains a sphere that represents the player. I can’t find out how to change the material of the prefab in each scene, because when I change the color then go to another scene, the material resets.
using UnityEngine;
public class Customization : MonoBehaviour {
// Variables
public Material[] material;
public int x;
public Renderer rend;
public GameObject _playerPrefab;
// Start is called before the first frame update
void Start () {
x=0;
rend.enabled =true;
rend.sharedMaterial = material[x];
}
// Update is called every frame
void Update () {
rend.sharedMaterial = material[x];
}
// Switches the material of the prefab
public void NextColor() {
if(x<7)
{
x++;
}
else
{
x=0;
}
}
// Goes back
public void Back() {
if(x>0)
{
x--;
}
else
{
x=8;
}
}
}