The best overloaded method match for 'System.Collections.Generic.List.Add(UnityEngine.GameObject)' has some invalid arguments

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Collections.Generic;

public class GameManager : MonoBehaviour {

public Button goBtn;
public GameObject Pin;

public List<GameObject> Pins;
private int pinIndex;

public int totalPins;

private float pinDistance = 0.5f;

private bool upPin;

public Vector3 temp;

public float _y;

private int passadas;

// Use this for initialization
void Awake ()
{
    getButton();
}

// Update is called once per frame
void Update () {

}

void getButton()
{
    goBtn.onClick.AddListener(() => CreatePin());
}

public void CreatePin()
{
    Instantiate(Pin, transform.position, Quaternion.identity);
}

void CreateListPins()
{
    Pins = List<UnityEngine.GameObject>();

    temp = transform.position;

    for (int i = 0; i < totalPins; i++)
    {
        Pins.Add(Instantiate(Pin, temp, Quaternion.identity));
        temp.y -= pinDistance;
    }
}

private List<GameObject> List<T1>()
{
    throw new System.NotImplementedException();
}

}

Error 1 The best overloaded method match for ‘System.Collections.Generic.List<UnityEngine.GameObject>.Add(UnityEngine.GameObject)’ has some invalid arguments C:\Users\Root\Documents\ok\Assets\Scripts\GameManager.cs 56 13 Assembly-CSharp

Error 2 Argument 1: cannot convert from ‘UnityEngine.Object’ to ‘UnityEngine.GameObject’ C:\Users\Root\Documents\ok\Assets\Scripts\GameManager.cs 56 22 Assembly-CSharp

Help Me Pls

Instantiate returns an object. Your Pins.Add() function requires a GameObject.
You need to cast the returned Object to GameObject. In Line 49, replace:

 Pins.Add(Instantiate(Pin, temp, Quaternion.identity));

with

 Pins.Add((GameObject)Instantiate(Pin, temp, Quaternion.identity));

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Collections.Generic;

public class GameManager : MonoBehaviour {

public Button goBtn;
public GameObject Pin;

public List<GameObject> Pins;
private int pinIndex;

public int totalPins;

private float pinDistance = 0.5f;

private bool upPin;

public Vector3 temp;

public float _y;

private int passadas;

// Use this for initialization
void Awake ()
{
    getButton();
    CreateListPins();
}

// Update is called once per frame
void Update () {

}

void getButton()
{
    goBtn.onClick.AddListener(() => CreatePin());
}

public void CreatePin()
{
    Instantiate(Pin, transform.position, Quaternion.identity);
}

void CreateListPins()
{
    Pins = new List<GameObject>();

    temp = transform.position;

    for (int i = 0; i < totalPins; i++)
    {
        Pins.Add(Instantiate(Pin, temp, Quaternion.identity) as GameObject);
        temp.y -= pinDistance;
    }
}

}

Perfectly :slight_smile: Thanks Closed Questions :slight_smile: