Trying to remove a game object from the screen and replacing it with a GUITexture. The problem is that I get an error I try to instantiate anything other than GameObjects.
using UnityEngine;
using System.Collections;
public class object_temp : MonoBehaviour {
public Texture[] ScoreTex;
public GUITexture ScoreHolder;
public GUIText ScoreText;
//public GameObject GUIholder;
private int rand;
//private bool guiScore;
//private float posX;
//private float posY;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnMouseDown()
{
rand = Random.Range(0,2);
//guiScore = rand;
ScoreHolder.texture = ScoreTex[rand];
//posX = this.transform.position.x;
//posY = this.transform.position.y;
Destroy(this);
if(rand == 1)
{
ScoreText.text = "20";
ScoreHolder = Instantiate(ScoreHolder);
ScoreHolder.transform.position = this.transform.position;
}
else
{
ScoreText.text = "10";
ScoreHolder = Instantiate(ScoreHolder);
ScoreHolder.transform.position = this.transform.position;
}
Debug.Log("MouseDown");
}
}