2D Toolkit Forum

2D Toolkit => Support => Topic started by: tunahantolga on July 25, 2013, 11:35:54 am

Title: Material.SetTextureOffset function is not working!
Post by: tunahantolga on July 25, 2013, 11:35:54 am
Hello,

I am making jumping game and I have a problem.(I am using Unity 4 and 2D Toolkit.) I want to background scroll.Normally function is running  in Unity but if I use  2D Toolkit is not running.

Here is the code:

    public float scroolSpeed = 0.2F;
    public float offset;

 void Update () {
         offset = Time.time * scroolSpeed;
        renderer.material.SetTextureOffset("_MainTex", new Vector3(0, Time.time * scroolSpeed));
   }

simply can't work why? 
Please help guys.
Title: Re: Material.SetTextureOffset function is not working!
Post by: unikronsoftware on July 25, 2013, 11:41:41 am
It won't work because the shader doesn't support it.
Since the texture is now atlased, it will not actually scroll properly - look at the atlas texture and you'll understand why. If you want a scrolling background, you should just create multiple sprites side by side and physically scroll and wrap them instead.
Title: Re: Material.SetTextureOffset function is not working!
Post by: tunahantolga on July 25, 2013, 11:50:13 am
Thank you! I will try it.