Hi, everyone, I am a fresher in Unity programm, right now I want to set array texture to array Guitexture, eg. I want to texture 1 to bound with GUItexture 1, something like this, and I write the code in C# like this
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public GUITexture[ ] gui;
public Texture2D[ ] someTexture = new Texture2D[0];
void Awake() {
gui.texture = someTexture;
}
}
but I got this warning UnityEngine.GUITexture[ ]’ does not contain a definition for texture' and no extension method texture’ of type `UnityEngine.GUITexture[ ]’ could be found (are you missing a using directive or an assembly reference?)
I know something is wrong, but I do not know how to fix it, hope you guys can help me, thank you so much.
thanks so much for you reply, after I add your code in,
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public GUITexture[ ] gui;
public Texture2D[ ] someTexture = new Texture2D[0];
void Awake() {
gui = new GUITexture[someTexture.Length];
for(int i=0;i<someTexture.Length;i++) {
gui_.texture = someTexture*;_
_}_
_}_
_}*_ everything is fine untill I press the play button. I create a game object and drag the script on it, and I also creat two gui texture to apply to the game object, when I press play button, it give me this warning NullReferenceException: Object reference not set to an instance of an object NewBehaviourScript.Awake () (at Assets/Scripts/NewBehaviourScript.cs:16) I am pretty sure I put the two gui texture in the two elements slots, but when I press play, it is gone, like this