Hello!
public class block
{
public Texture2D textura;
public Vector2 position;
public void addBlock(Texture2D iTexture, Vector2 iPosition)
{
textura = iTexture;
position = iPosition;
Sprite block = new Sprite ();
block = Sprite.Create (textura, new Rect (0, 0, 100, 100), position);
new GameObject().AddComponent<SpriteRenderer> ().sprite = block;
}
public void Update()
{
position += new Vector2 (0.1f, 0);
}
}
(...)
List<block> blocks = new List<block>();
(...)
block block = new block();
block.addBlock(texture, new Vector2(x, y);
blocks.Add(block);
(...)
I write class, and
if(blocks[0] != null)
blocks [0].Update ();
Unfortunately, the sprite is not moving. Why?
I very sorry for my English, but I don't know this language well.