ga.tender.material = mats[index];
->
ga.renderer.material = mats[index];
GUILayout.BeginArea(new Rect(Screen.with / 2 - 100, Screen.height - 60, 200, 50));
->
GUILayout.BeginArea(new Rect(Screen.width / 2 - 100, Screen.height - 60, 200, 50));
index = mats.length - 1;
->
index = mats.Length - 1;
if(GUI.Button(new Rect(165, 15, 30, 30); ">>")){
->
if(GUI.Button(new Rect(165, 15, 30, 30), ">>")){
ga.renderer.material - mats[index];
->
ga.renderer.material = mats[index];
This is an illustration of the errors you are getting. (which you NEED to look at before you post “I can’t figure out what is wrong”)
using UnityEngine;
using System.Collections;
public class test : MonoBehaviour {
GameObject ga;
Material[] mats;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
int index=0;
ga.tender.material = mats[index];
}
}
produces this error:
Assets/test.cs(15,20): error CS1061: Type `UnityEngine.GameObject' does not contain a definition for `tender' and no extension method `tender' of type `UnityEngine.GameObject' could be found (are you missing a using directive or an assembly reference?)
and it flat tells you… “tender is NOT part of a GameObject”
Look at the reference:
The others are a little harder.
The length is because the actual length of a Material[ ] is Length with a capitol L.
Screen.with, of course should be Screen.width
In your GUI.Button, you have accidentally put a semicolon in where a comma should have been.
And the last one is you accidentally hit minus instead of equals.
We all make dumb little mistakes. The only difference is that the vets look at the Console every time they save a piece of script out. I make so many dumb mistakes it can get real slow. We all understand being frustrated, but use the tools you have, and it will get better.