Author Topic: Scrolling texture (modifying uv rect) not working on iOS using Unity 4.3  (Read 9176 times)

UncleAcid

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 51
    • View Profile
Hi,

I have been scrolling a UITexture by modifying the UV Rect of the texture and it works great. I just updated to Unity 4.3 and everything is working fine, except this. In the editor it scrolls and repeats fine, however it doesn't repeat on iOS. Why would this stop working ?

Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrolling texture (modifying uv rect) not working on iOS using Unity 4.3
« Reply #1 on: November 15, 2013, 09:52:44 PM »
I'm not aware of something that would cause this to break. Unity 4.2 -> 4.3 is the only thing that has changed? When you say UV Rect, I am guessing you're talking about the one on the UITexture itself, right?

UncleAcid

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 51
    • View Profile
Re: Scrolling texture (modifying uv rect) not working on iOS using Unity 4.3
« Reply #2 on: November 18, 2013, 09:41:16 AM »
All i did was upgrade Unity and now it doesn't work. Yes, the one on UITexture. I have tried by scrolling the Material (as I would do if not using NGUI) but that has no effect.

EDIT) forgot to mention that I'm using NGUI 2.7.0. I know I shouldn't post unless using the latest but I can't switch at this stage in the project so I'm stuck on 2.7.0.
« Last Edit: November 18, 2013, 11:19:29 AM by UncleAcid »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrolling texture (modifying uv rect) not working on iOS using Unity 4.3
« Reply #3 on: November 18, 2013, 11:17:15 AM »
Based on a cursory glance it seems to work correctly on my end, but I wasn't modifying the material. I was modifying the UV Rectangle field on the UITexture. Also, make sure the texture is set to "repeat".

UncleAcid

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 51
    • View Profile
Re: Scrolling texture (modifying uv rect) not working on iOS using Unity 4.3
« Reply #4 on: November 18, 2013, 11:22:38 AM »
this is the code i've been using:

  1. public void Update()
  2. {
  3.         Rect currentUV = texture.uvRect;
  4.         currentUV.x += Time.deltaTime * scrollSpeed;
  5.                
  6.         if(currentUV.x <= -1f || currentUV.x >= 1)
  7.         {
  8.                 currentUV.x = 0f;
  9.         }
  10.  
  11.         texture.uvRect = currentUV;
  12. }
  13.  

It scrolls fine, only the texture is not repeated (it is set to repeat in the import settings).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrolling texture (modifying uv rect) not working on iOS using Unity 4.3
« Reply #5 on: November 18, 2013, 11:40:30 AM »
Double-check your iOS import settings on the texture. It may be different from your desktop settings, and set to be clamped instead of repeat. That would be the only thing that would cause this. Short of that, bug report to Unity regarding a regression bug in 4.3.

UncleAcid

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 51
    • View Profile
Re: Scrolling texture (modifying uv rect) not working on iOS using Unity 4.3
« Reply #6 on: November 18, 2013, 12:33:57 PM »
OK, so I had all the settings and everything correct however when building for iOS it appears that behind the scenes Unity changes the texture to Clamped and then changes it back to Repeat after the build is done.

I put in a check to set the texture to Repeat if it isn't but that is resulting in a black texture on iOS.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrolling texture (modifying uv rect) not working on iOS using Unity 4.3
« Reply #7 on: November 19, 2013, 06:11:24 PM »
Make sure the texture you're using is power-of-two. Ie: 500x500 won't work but 512x512 should work just fine.

amraffay

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 37
    • View Profile
Hi there,

I used above code and in my case both texture scrolling and repeating is working, however there is noticable stutter/jerk/jumps. I know this issue is due to when uv value not properly stepping (from 0.0 to 1.0 to 0.0 and so on)

However i havent seen this issue in other games, what should i do?

Regards