Hello, I was working on my game when I tried to Instantiate a GameObject as a child and got errors.
Code:
using UnityEngine;
using System.Collections;
public class InCorrect : MonoBehaviour {
public Transform Canvas;
GameObject Correct;
public GameObject CorPrefab;
GameObject Incorrect;
public GameObject IncPrefab;
// Use this for initialization
void Start () {
Correct = Instantiate (CorPrefab, new Vector3 (0f,0f,0f), Quaternion.identity);
Correct.transform.parent = Canvas;
}
// Update is called once per frame
void Update () {
}
}