Hello guys/girls I need a little bit of help here.
I had placed on the top of the screen some items that you can found them on the ground like weapons etc.
The problem is that when they are less or equal to 3 they can fit on the screen, but if they are more than 3 they just go trough borders.
Here is an example to be more clear
[29286-безымянный.png|29286]
I need a way to scale them down or to scale them just a little bit and to put on two rows.
Any help will be appreciated.
Here is my code to instantiate them
public void CreateItems(float i, int numberOfObjects, float iterator, float offsetX, float yPosition, GameObject itemPrefab)
{
numberOfObjects = objectScript.ItemsNumber;
string letter = objectScript.ItemsColor;
GameObject cube = null;
switch(letter)
{
case "B":
cube = Item_bbg;
break;
case "G":
cube = Item_gbg;
break;
case "O":
cube = Item_obg;
break;
case "P":
cube = Item_pbg;
break;
case "R":
cube = Item_rbg;
break;
case "Y":
cube = Item_ybg;
break;
default: break;
}
//impar
if(numberOfObjects % 2 != 0)
{
iterator = -numberOfObjects +1;
offsetX = 2f;
for(i = iterator; i < numberOfObjects ; i += offsetX)
{
GameObject clone = Instantiate (cube, new Vector3 (i , yPosition, -1), Quaternion.identity) as GameObject;
prefabs.Add(clone);
}
}
//par
else
{
iterator = - numberOfObjects +1;
offsetX = 2.0f;
if(numberOfObjects !=0 )
{
for(i = iterator; i < numberOfObjects ; i += offsetX)
{
GameObject clone = Instantiate (cube, new Vector3 (i , yPosition, -1), Quaternion.identity) as GameObject;
prefabs.Add(clone);
}
}
}
// Check for exceptions case
if(numberOfObjects == 0)
{
return;
}
}