Static class member for offset

I have a public class for my items, and List for that items which is empty at the begining.

Ech time I click on object on screen (“GUITexture”), I instantiate a itemList Class and add it to a item List, then I render them on GUI from for loop.

My constructor for itemList class needs two parametars 1-name and 2-texture.

Everything works, adding to list, displaying from list, draging from list… but the order on screen is not good!

I tryed with static float for my X position, and each time the class is instantiated I want it to increase by 60;

I make it default 10, but when I print that default value I get 360???

I want to make dynamic offset of X value for Rect for each new class instance…

here is the code for class:

[System.Serializable]
public class itemsList{	
	public bool drag;
	public string name;
	//GUITexture textura;
    public static float pX = 10;
	public Texture myTexture;
	public float pY;
	public float width;
	public float height;
	public Rect myRect;
	public itemsList(){}
	public itemsList(string ime, Texture slika){
		name = ime;
		drag = false;
		width = 50;
		height = 50;
		myTexture = slika;
		pY = 50;
		myRect = new Rect(itemsList.pX,pY,width,height);
		itemsList.pX += 60;
		return;
	}	
}

You are printing the value AFTER all itemsList constructors are called. That’s why your print(itemsList.pX) prints 360.

Check where you are creating the instances and where you are calling print(itemsList.pX).