Why does my List doesn't count?

Hello Guys. I’m working on a build queue and everything works except that the icons can’t tween to the right spots because my Count of buildQueue always stays 1. So I can add an Icon once but then not. Is there a way to store the value? I didn’t saw any other people have problems with the Count not increasing so I’m sure I’m doing something completly wrong but can’t find ist.

public class BuildQueue : MonoBehaviour
    private float currentBuildTime;
    int queueMax = 5;

    public GameHandler gameHandler;

    public GameObject spawnPoint;
    private Vector3 entrancePosition;
    private Vector3 targetPosition;
    private List<Vector3> positionList;
    private List<GameObject> buildQueue;
    private List<GameObject> currentQueue;

    private void Start() {
        buildQueue = new List<GameObject>();            

    void Update() {

    public BuildQueue(List<Vector3> positionList) {
        this.positionList = positionList;  
              entrancePosition = positionList[positionList.Count - 1] + new Vector3(0.5f, 0);

        foreach (Vector3 position in positionList) {
            World_Sprite.Create(position, new Vector3(.3f, .3f), Color.green);
        World_Sprite.Create(entrancePosition, new Vector3(.1f, .1f), Color.magenta);      

    private void UpdateBuildTime() {
        if (buildQueue.Count > 0 ) {
            currentBuildTime += Time.deltaTime;
            if (currentBuildTime >= buildQueue[0].gameObject.GetComponent<Icon>().buildTime)

            currentBuildTime = 0;
        } else {

    public void AddUnitToBuildQueue(GameObject icon) {
        if (buildQueue.Count <= queueMax) { 
        GameObject newIcon = icon;
        Debug.Log("PositionList Count: " + gameHandler.buildQueue.positionList.Count.ToString());
        Debug.Log("buildList Count:" + buildQueue.Count.ToString());
        newIcon.GetComponent<Icon>()._tweenFlag = true;
        newIcon.transform.position = gameHandler.buildQueue.entrancePosition;
        Vector3 targetPosition = gameHandler.buildQueue.positionList[gameHandler.buildQueue.positionList.Count - 1] + new Vector3(0.5f, 0);
        newIcon.GetComponent<Icon>()._targetPos = targetPosition;
            Debug.Log("Icon addded" + icon.ToString());

        } else {
            Debug.Log("Queue is full bruh");

    private void SpawnUnit(GameObject unit) {
        var pos = new Vector2(spawnPoint.transform.position.x, spawnPoint.transform.position.x);
        Instantiate(unit.GetComponent<Icon>().unitPrefab, pos, Quaternion.identity);

    public void RelocateAllIcons() {
        for (int i = 0; i < buildQueue.Count; i++) {
            buildQueue_.transform.position = gameHandler.buildQueue.positionList*;*_



Your buildQueue.Count should automatically increment when you add something to the list by buildQueue.Add() … (what you actually do in line 57).

So, are you sure, that this line is reached and executed successfully, when you call your AddUnitToBuildQueue() method?

And there is maybe one other problem: At the moment you are always adding the newIcon to the list, which is actually only a reference to the icon, which you have in the parameters. But then in the next line you Instantiate it. And Instantiate() actually return also a new Object. So maybe you just take this and add it to your list instead. Something like this:

GameObject tmp = Instantiate(newIcon);