`UnityEngine.Object' does not contain a definition for `GetComponent' and no extension method `GetComponent' of type `UnityEngine.Object' could be found (are you missing a using directive or an assembly reference?)

Hello everyone

I’m sorry for my bad English. I need a help. Here is the script.

using UnityEngine;
using System.Collections;

public class Arkaplan : MonoBehaviour {

    public GameObject gokyuzu;
    public GameObject toprak;

    int arkaplanSayisi;

    Vector2 kameraUnityEbatlar;
    Vector2 gokyuzuUnityEbatlar;
    Vector2 toprakUnityEbatlar;

    Transform[] gokyuzuObjeleri;
    Transform[] toprakObjeleri;
    int bastakiArkaplanObjesi = 0;

    void Start()
    {
        
        gokyuzuUnityEbatlar = new Vector2((gokyuzu.GetComponent<Renderer>() as SpriteRenderer).sprite.rect.width, (gokyuzu.GetComponent<Renderer>() as SpriteRenderer).sprite.rect.height) / 100;
        toprakUnityEbatlar = new Vector2((toprak.GetComponent<Renderer>() as SpriteRenderer).sprite.rect.width, (toprak.GetComponent<Renderer>() as SpriteRenderer).sprite.rect.height) / 100;

        GetComponent<Camera>().orthographicSize = (gokyuzuUnityEbatlar.y + toprakUnityEbatlar.y) / 2;
        arkaplanSayisi = Mathf.CeilToInt((GetComponent<Camera>().orthographicSize * 2 * GetComponent<Camera>().aspect) / gokyuzuUnityEbatlar.x) + 1;

        kameraUnityEbatlar = new Vector2(GetComponent<Camera>().orthographicSize * GetComponent<Camera>().aspect, GetComponent<Camera>().orthographicSize);

        gokyuzuObjeleri = new Transform[arkaplanSayisi];
        toprakObjeleri = new Transform[arkaplanSayisi];
        

        for(var i = 0; i < arkaplanSayisi; i++)
        {
            float xKoordinati = transform.position.x - kameraUnityEbatlar.x + i * gokyuzuUnityEbatlar.x;
            gokyuzuObjeleri *= (Transform)Instantiate(gokyuzu, new Vector3(xKoordinati, kameraUnityEbatlar.y, 0), Quaternion.identity).GetComponent(Transform);*

toprakObjeleri = (Transform)Instantiate(toprak, new Vector3(xKoordinati, kameraUnityEbatlar.y - gokyuzuUnityEbatlar.y, 0), Quaternion.identity).GetComponent(Transform);
}
}

void Update()
{
if (transform.position.x - kameraUnityEbatlar.x >= gokyuzuObjeleri[bastakiArkaplanObjesi].transform.position.x + gokyuzuUnityEbatlar.x)
{

gokyuzuObjeleri[bastakiArkaplanObjesi].transform.position = new Vector3(gokyuzuObjeleri[bastakiArkaplanObjesi].transform.position.x + arkaplanSayisi * gokyuzuUnityEbatlar.x, gokyuzuObjeleri[bastakiArkaplanObjesi].transform.position.y, gokyuzuObjeleri[bastakiArkaplanObjesi].transform.position.z);
toprakObjeleri[bastakiArkaplanObjesi].transform.position = new Vector3(toprakObjeleri[bastakiArkaplanObjesi].transform.position.x + arkaplanSayisi * gokyuzuUnityEbatlar.x, toprakObjeleri[bastakiArkaplanObjesi].transform.position.y, toprakObjeleri[bastakiArkaplanObjesi].transform.position.z);

bastakiArkaplanObjesi++;

if (bastakiArkaplanObjesi == gokyuzuObjeleri.Length)
bastakiArkaplanObjesi = 0;
}
}
}
Errors are in these lines:
gokyuzuObjeleri = (Transform)Instantiate(gokyuzu, new Vector3(xKoordinati, kameraUnityEbatlar.y, 0), Quaternion.identity).GetComponent(Transform);
toprakObjeleri = (Transform)Instantiate(toprak, new Vector3(xKoordinati, kameraUnityEbatlar.y - gokyuzuUnityEbatlar.y, 0), Quaternion.identity).GetComponent(Transform);

Both errors are CS1061: Type UnityEngine.Object' does not contain a definition for GetComponent’ and no extension method GetComponent' of type UnityEngine.Object’ could be found (are you missing a using directive or an assembly reference?)

Yeah i see the problem here. Take for example this line:

gokyuzuObjeleri *= (Transform)Instantiate(gokyuzu, new Vector3(xKoordinati, kameraUnityEbatlar.y, 0), Quaternion.identity).GetComponent(Transform);*

If we simplify this piece of code, it will look something like this:
gokyuzuObjeleri = (Transform) Instantiate(…).GetComponent(Transform);
Problems:
Instantiate will return an Object.
//This is of type Object.
Instantiate(…)
//The type Object doesnt have a Transform component.
Instantiate(…).GetComponent();
//Even when we have a (Transform) cast, the Instantiate(…) is still an Object.
(Transform) Instantiate(…).GetComponent();
So we need to break up this code in to more pieces to make it to work:
//We create a temporary variable to cast our instantiation in:
Transform temporary = (Transform) Instantiate(…);
//Now we can safely get the Transform component, cause we are sure it has a Transform:
gokyuzuObjeleri = temporary.GetComponent();
Hope i have informed you enough for you to continue.