I am making a 2d game and to make movement visible to the user when there are no other objects on the screen the background needs to scroll. Currently I have an object comprising of a quad and a mesh renderer attached as a child to my camera object.
Using the code below the background follows the camera (because it is a child) and the texture scrolls in the correct direction at the correct speed. However the material that is offset does not follow the camera, leaving me with black space (with some weird streaks) once I move out of the original background area.
void Update () {
offset = (cameraLocation.transform.localPosition*scrollSpeed);
//renderer.material.SetTextureOffset("_MainTex", offset);//This has the same effect
renderer.material.mainTextureOffset = offset;
}
I cannot find any solutions in the documentation for SetTextureOffset etc and I cant find anyone else with this issue. Any help would be most appreciated.