public int xlimit= 21;
public int ylimit= 11;
public int xoffset= 7;
public GameObject foodprefab:
public Sprite[] foodsprites;
private Transform foodHolder;
void Start()
foodHolder=GameObject.Find("FoodHolder").transform; MakeFood();
void MakeFood(){
int index = Random.Range(0,foodsprites.Length);
GameObject food = Instantiate(foodPrefab);
food.GetComponent<Image>().sprite=foodsprites[index];
food.transform.SetParent(foodHolder,false);
int x= Random.Range(-xlimit +xoffset,xlimit);
int y = Random.Range(-ylimit,ylimit);
food.transform.localPosition = new Vector3(x* 30,y* 30,0);
}