When I am instantiating prefab as GameObject there is no problem. But when instantiating prefab as RawImage there is NullReferenceException problem. (Prefab is RawImage if you need to know)

This is my code:

```
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Insstantia : MonoBehaviour
{
    public GameObject img;

    public void Instan()
    {
        RawImage[] myObject = new RawImage[8];
        RectTransform[] rt = new RectTransform[8];

        for (int i = 0; i < 8; i++)
        {
            myObject[i] = Instantiate(img, new Vector3(800 * i, 0, 0), Quaternion.identity) as RawImage;
            rt[i] = myObject[i].GetComponent<RectTransform>();
            myObject[i].transform.SetParent(gameObject.transform, false);

            rt[i].anchorMin = new Vector2(0.05875f, 0);
            rt[i].anchorMax = new Vector2(0.94375f, 1);
        }
    }
 }

```