Hello Guest

Author Topic: Material.SetTextureOffset function is not working!  (Read 7217 times)

tunahantolga

  • Newbie
  • *
  • Posts: 12
    • View Profile
Material.SetTextureOffset function is not working!
« 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.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Material.SetTextureOffset function is not working!
« Reply #1 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.

tunahantolga

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Material.SetTextureOffset function is not working!
« Reply #2 on: July 25, 2013, 11:50:13 am »
Thank you! I will try it.