Quantcast
Channel: Forum Pasja Informatyki - Najnowsze pytania bez odpowiedzi
Viewing all articles
Browse latest Browse all 21942

Zmiana textury skrytptem

$
0
0

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 ?


Viewing all articles
Browse latest Browse all 21942

Trending Articles


TRX Antek AVT - 2310 ver 2,0


Автовишка HAULOTTE HA 16 SPX


POTANIACZ


Zrób Sam - rocznik 1985 [PDF] [PL]


Maxgear opinie


BMW E61 2.5d błąd 43E2 - klapa gasząca a DPF


Eveline ➤ Matowe pomadki Velvet Matt Lipstick 500, 506, 5007


Auta / Cars (2006) PLDUB.BRRip.480p.XviD.AC3-LTN / DUBBING PL


Peugeot 508 problem z elektroniką


AŚ Jelenia Góra