How to scroll a big image in backgroud?
Could any guys give me help?
Thx a lot in advance.
You probably want to use SetTextureOffset.
_ This is an example using SetTextureOffset
:
// Scroll main texture based on time
var scrollSpeed : float = 0.5;
function Update () {
var offset : float = Time.time * scrollSpeed;
renderer.material.SetTextureOffset ("_MainTex", Vector2(offset,0));
}
[Unity - Scripting API: Material.SetTextureOffset][1] : Unity Script Reference
_ This is an example for swapping the UV’s of the mesh vertices.
#pragma strict
public var scrollSpeed : float = 0.1;
function Update()
{
SwapUVs();
}
function SwapUVs()
{
var mesh : Mesh = this.transform.GetComponent(MeshFilter).mesh;
var uvSwap : Vector2[] = mesh.uv;
for (var b:int = 0; b < uvSwap.length; b ++)
{
uvSwap __+= Vector2( scrollSpeed * Time.deltaTime, 0 );__
}
mesh.uv = uvSwap;
}
[1]: Unity - Scripting API: Material.SetTextureOffset
Thx,i’ll try it later.