How do I assign one gameObject to another?

0

I have a question about the C # language using Unity I was wondering how can I get a gameObject and assign to another gameObject .

I created a array with 4 gameObjects with images and wanted to assign those gameObjects to a button when I started the project.

public Text pergunta;
public GameObject img1;
public GameObject img2;
public GameObject img3;
public GameObject img4;

public Text infoResposta;

public string[] perguntas;
public GameObject[] respostaA;
public GameObject[] respostaB;
public GameObject[] respostaC;
public GameObject[] respostaD;

public string[] corretas;

private int idPergunta;

private float acertos;
private float qntQuestoes;
private float media;

void Start(){
    idPergunta = 0;
    qntQuestoes = perguntas.Length;
    img1 = gameObject.GetComponent(respostaA[0]);
}

I can not assign gameObject img1 to gameObject repostaA[0] .

    
asked by anonymous 20.05.2018 / 04:49

0 answers