// Instantiates an Item and places it on the position from the input Item GenerateItem(int itemNumber, Vector2 itemPosition) { GameObject instance = Instantiate(CityItemPrefab, itemPosition, Quaternion.identity) as GameObject; if (itemNumber == GameManager.wcsppInstances[currInstance].startcity) { instance = Instantiate(StartCityPrefab, itemPosition, Quaternion.identity) as GameObject; } else if (itemNumber == GameManager.wcsppInstances[currInstance].endcity) { instance = Instantiate(EndCityPrefab, itemPosition, Quaternion.identity) as GameObject; } canvas = GameObject.Find("Canvas"); instance.transform.SetParent(canvas.GetComponent <Transform>(), false); Item itemInstance; itemInstance.gameItem = instance; itemInstance.CityButton = itemInstance.gameItem.GetComponent <Button>(); itemInstance.CityNumber = itemNumber; itemInstance.center = itemPosition; //itemInstance.CityButton.GetComponent<Image>().sprite = Resources.Load<Sprite>("CityVisited"); // Setting the position in a separate line is importatant in order to set it according to global coordinates. BoardFunctions.PlaceItem(itemInstance, itemPosition); return(itemInstance); }