I want to repeat a sprite for a background. I cant use the material tilling method because it seem to come in contradiction with 2ddl . Anyhow, I know someone post this wonderfull code thanks to ash blue
the problem is it only tile in vertical and I am not sure to know how to do so that t tile both verticxaly and horizontally. I tried a for method inside a for method or adding this script
void Start () {
sprite = GetComponent<SpriteRenderer>();
Vector2 spriteSize = new Vector2(sprite.bounds.size.x / transform.localScale.x, sprite.bounds.size.y / transform.localScale.y);
GameObject child;
for (int i = 1, l = (int)Mathf.Round(sprite.bounds.size.x); i < l; i++) {
child = Instantiate(Tile) as GameObject;
child.transform.position = transform.position - (new Vector3(spriteSize.x, 0, 0) * i);
child.transform.parent = transform;
}
Tile.transform.parent = transform;
// Disable the currently existing sprite component since its now a repeated image
sprite.enabled = false;
}
// Update is called once per frame
void Update () {
}
}
who basicallu repeat the object that was repeating, anywaym both solution does not work and I am not that familiair with the for method