Animated texture on linerenderer

Hey there,

Just wanted to ask if it is possible to add an animated textre to a linerenderer and if so how to do it.

Thanks

Frogsbo is correct. 226. Unity3d Tutorial - Animated Texture - YouTube explains how to do this with a standard mesh renderer and I have confirmed that it works the same way with a line renderer.

Below is a C# version of the animated UV texture script found here: http://wiki.unity3d.com/index.php?title=Animating_Tiled_texture

Just make sure you adjust your uvAnimationTile X and Y variables to match your texture.

    int uvAnimationTileX = 4;
    int uvAnimationTileY = 16;

    float framesPerSecond = 30.0f;

    void Update()
    {
        // Calculate index
        int index = (int)(Time.time * framesPerSecond);
        // repeat when exhausting all frames
        index = index % (uvAnimationTileX * uvAnimationTileY);

        // Size of every tile
        var size = new Vector2(1.0f / uvAnimationTileX, 1.0f / uvAnimationTileY);

        // split into horizontal and vertical index
        var uIndex = index % uvAnimationTileX;
        var vIndex = index / uvAnimationTileX;

        // build offset
        // v coordinate is the bottom of the image in opengl so we need to invert.
        var offset = new Vector2(uIndex * size.x, 1.0f - size.y - vIndex * size.y);

        GetComponent<Renderer>().material.SetTextureOffset("_MainTex", offset);
        GetComponent<Renderer>().material.SetTextureScale("_MainTex", size);
    }