I'm new in Unity, so I hope you guys can help. I'm developing a 2D-game for Android device, on the scene I have a huge background image inside Scroll View (UI - Scroll View).
Next, I created new empty Game Object "Players", attached to it "Players script" and added "Sprite Renderer" component.
From the Sprites I created two prefabs - housePrefab and dogPrefab. Inside "Players script" I have the following code:
[SerializeField] GameObject housePrefab;
[SerializeField] GameObject dogPrefab;
void Start()
{
var houseXPos = 1.41f;
var houseYPos = 2.63f;
var dogXPos = -0.41f;
var dogYPos = 2.63f;
GameObject house = Instantiate(housePrefab, transform.position = new Vector2(houseXPos, houseYPos), Quaternion.identity) as GameObject;
GameObject dog = Instantiate(dogPrefab, transform.position = new Vector2(dogXPos, dogYPos), Quaternion.identity) as GameObject;
}
After I run game both Sprites appears on the screen (as I expected). The problem occurs when I Scroll background image, both sprites stay in the same position under scrolling. In other words sprites not scrolling with the background image.
As far as I understand, the Sprites needs to be added to the background image, but I don’t know how to do it. How to make Sprites scroll with the background image?
Thanks to all in advance.