Witam. Mam problem odnośnie zmiany textury. W mojej grze zrobiłem sklep w którym można kupować różne wyglądy dla obiektu gracza. Robię to za pomocą takiego skryptu:
using UnityEngine;
using System.Collections;
public class ZmianaKoloru : MonoBehaviour {
public int punkty = 0;
public int index = 0;
//public Material[] materials;
public Material[] zmianaskina;
public Renderer rend;
public int cost = 100;
public int cost2 = 200;
public int cost3 = 300;
public void Start(){
rend = GetComponent<Renderer> ();
rend.enabled = true;
index = 1;
}
public void ZmianaSkina1()
{
rend.sharedMaterial = zmianaskina [0];
PlayerPrefs.SetInt ("TotalMoney", PlayerPrefs.GetInt ("TotalMoney")- cost);
PlayerPrefs.Save();
}
public void ZmianaSkina2()
{
rend.sharedMaterial = zmianaskina [1];
PlayerPrefs.SetInt ("TotalMoney", PlayerPrefs.GetInt ("TotalMoney")- cost2);
PlayerPrefs.Save();
}
public void ZmianaSkina3()
{
rend.sharedMaterial = zmianaskina [2];
PlayerPrefs.SetInt ("TotalMoney", PlayerPrefs.GetInt ("TotalMoney")- cost3);
PlayerPrefs.Save();
}
}
Oczywiście w miejsce renderu podstawiony jest render obiektu gracza. Funkcję wywołuję przyciskiem lecz nic się nie dzieje. Co może być nie tak ?