- Select the original Texture (not the GameObject).
- Change
Texture TypetoSprite (2D and UI). - Change
Wrap ModetoRepeat. - Click
Apply. - Create a
Quadobject:GameObject -> 3D Object ->Quad. - Scale the
Quadto the size you want. - Create a light:
GameObject->Light->Directional Light. - Adjust the light intensity to whatever you like.
- Drag your Texture/Sprite to the
Quadin the Scene View.
Now, create your script:
public class OffsetScrolling : MonoBehaviour {
public float scrollSpeed;
private Renderer renderer;
private Vector2 savedOffset;
void Start () {
renderer = GetComponent<Renderer> ();
}
void Update () {
float x = Mathf.Repeat (Time.time * scrollSpeed, 1);
Vector2 offset = new Vector2 (x, 0);
renderer.sharedMaterial.SetTextureOffset("_MainTex", offset);
}
}Note: For 2D, you can also use a Plane and the code above should work fine.
References:
Thank you very much for sharing!