Code : Tout sélectionner
using UnityEngine;
using System.Collections;
public class SceneGUI : MonoBehaviour {
public Material[] mats;
public GameObject ga;
private int index = 0;
void Start () {
ga.renderer.material = mats[index];
}
public void OnGUI() {
GUILayout.BeginArea(new Rect(Screen.width / 2 - 100, Screen.height - 60, 200, 50));
GUI.Box(new Rect(10, 10, 190, 40),"");
GUI.Label(new Rect(62, 20, 100, 20), "Car Texture " + (index + 1));
if(GUI.Button(new Rect(15, 15, 30, 30), "<<")){
index--;
if(index < 0) {
index = mats.Length - 1;
}
ga.renderer.material = mats[index];
}
if(GUI.Button(new Rect(165, 15, 30, 30), ">>")){
index++;
if(index >mats.Length - 1) {
index = 0;
}
ga.renderer.material = mats[index];
}
GUILayout.EndArea ();
}
}
>Golf3
.. >Chassis
.. >Capot
..>Pare-choc
..etc...
Lorsque je choisis l'objet Golf3 j'ai un message d'erreur m'indiquant que golf 3 n'a pas de "renderer" et qu'un script essaye de l'atteindre. Comment signifier à mon script qu'il doit aller chercher le renderer des enfants attachés à Golf3?
Merci de votre aide