Author Topic: UITexture not displaying until transform is repositioned  (Read 17294 times)

hummada23

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 45
    • View Profile
UITexture not displaying until transform is repositioned
« on: November 20, 2013, 06:07:57 AM »
Hi,

I have a UITexture in my scene that will not display on the screen until I click on the game object's transform and move it slightly. Does anybody know why this might be, and how I can fix it? I've tried refreshing it, disabling it and then re-enabling it, etc but nothing else seems to work. The problem occurs outside the Unity Editor as well.

Some points of possible note: I am changing the alpha of the texture through script, but even when fully opaque the image won't display until I move it slightly. The texture is using the unlit/transparent coloured shader. Once I've moved it, the image can be seen (and the alpha adjusted through script) without any problems, even when I move it back into its original position.

Any help would be greatly appreciated!


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITexture not displaying until transform is repositioned
« Reply #1 on: November 20, 2013, 03:16:57 PM »
I did a fair bit of tweaks on UITexture in 3.0.6. I'm guessing the issue will be already fixed when you update. 3.0.6 is in the Pro repository right now, so if you don't have access to that you should be able to grab it from the Asset Store this weekend.

hummada23

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 45
    • View Profile
Re: UITexture not displaying until transform is repositioned
« Reply #2 on: November 20, 2013, 06:09:50 PM »
OK great, thanks.

hummada23

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 45
    • View Profile
Re: UITexture not displaying until transform is repositioned
« Reply #3 on: November 22, 2013, 08:41:40 AM »
Just thought I'd add to this: I'm getting the same problem when I try to fade in a UI Spliced Sprite using TweenColor. That is, the sprite won't display (even if it is completely opaque) until I move its transform.

I haven't tried to upgrade to the latest version of NGUI yet- this will take a considerable amount of time.

matdru

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: UITexture not displaying until transform is repositioned
« Reply #4 on: November 22, 2013, 09:42:29 AM »
Hello, same issue for me i have lots of toggle's inside a scrollable view and randomly the checkmark doesn't appear when i click on some of them ( which is a UISprite fading in/out using alpha tween ) until i scroll the view a bit or change checkmark position slightly in unity editor. Then it appears and stays visible nicely and i can move it around and i can fade in/out without issues. What's worth noticing is that it doesn't happen always and for example, if i notice a position where it occurs i can't fade in the checkmark, but moving a bit and the checkmark appears, then with my check mark visible i'll get back on that buggy position and stay there -> toggle works perfectly. If i go out of buggy position, then fade out my checkmark and come back it just won't show ( even tough inspector receives touches for it and triggers fade in tween ). I hope my observation's will help finding cause of such behaviour  since as i can see i'm not the only one with this issue :)

Jodon

  • Guest
Re: UITexture not displaying until transform is repositioned
« Reply #5 on: November 22, 2013, 06:57:47 PM »
Hello, same issue for me i have lots of toggle's inside a scrollable view and randomly the checkmark doesn't appear when i click on some of them ( which is a UISprite fading in/out using alpha tween ) until i scroll the view a bit or change checkmark position slightly in unity editor.

I'm running into this issue right now.  I don't think it's UITexture related, instead it's probably related to UIDraggablePanel (at least in my case).  It seems that the UIDraggablePanel somehow interferes with clipping, causing the "checkbox" to not appear until its like 3rd or 4th time clicking it.  There are some changes to dragging in 3.0.6 so I hope this is addressed.  Really odd -- it only works 100% if I disable UIDraggablePanel.

hummada23

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 45
    • View Profile
Re: UITexture not displaying until transform is repositioned
« Reply #6 on: November 22, 2013, 08:33:39 PM »
Not sure if this will help others, but in my case I managed to get around the problem by changing the relevant NGUI class to make sure it updates to the screen. Some might not consider this an acceptable solution, but it works.

So, for those interested, take the case where you're trying to fade in using a UI Spliced Sprite and TweenColor. If the sprite is only painting when you move the sprite's transform (or, as I noticed, when you make the sprite pixel perfect) then update the UITweener Update method so that on every update of the Tweener, it forces the sprite to become pixel perfect. You can add a flag to make sure this is only done when you're actually fading in.


matdru

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: UITexture not displaying until transform is repositioned
« Reply #7 on: November 25, 2013, 03:23:18 AM »
update the UITweener Update method so that on every update of the Tweener, it forces the sprite to become pixel perfect. You can add a flag to make sure this is only done when you're actually fading in.

Hi, if it's not that much of a deal for you, would you mind sharing a code snippet on how to force it? I'm kind of new to NGUI and feel a bit lost, have been reading throught UITweener but simple don't know where to look. Thanks in advance,

Cheers!

hummada23

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 45
    • View Profile
Re: UITexture not displaying until transform is repositioned
« Reply #8 on: November 25, 2013, 06:50:40 PM »
I've included the code below, but in my opinion you should only use it as a last resort. The solution is a hack: it requires changing an NGUI class directly, doesn't address the underlying problem, and may introduce further problems (which you couldn't reasonably expect anybody to be able to help you with). You're also going to need to redo the change every time you upgrade NGUI, and upgrades may introduce more problems.

Having said that, here's the code (this is what the top of the Update method in the UITweener class should look like):

   
  1. void Update ()
  2.         {
  3.                 float delta = ignoreTimeScale ? UpdateRealTimeDelta() : Time.deltaTime;
  4.                 if (Time.realtimeSinceStartup < mStartTime) return;
  5.  
  6.                 //Force your UISplicedSprite to repaint
  7.                 //Make sure overlayGUI is a game object that contains a UISlicedSprite
  8.                 //Make sure overlayGUI contains a public element called 'overlay', which is a cached reference
  9.                 //to the UISlicedSprite (you can cache this in the Start or Awake method of the overlayGUI
  10.                 //with 'overlay = GetComponent<UISlicedSprite>();'
  11.                 if (overlayGUI != null && NGUITools.GetActive(overlayGUI.gameObject))
  12.                         overlayGUI.overlay.MakePixelPerfect();

In my case, the overlayGUI is only active when I'm fading it in, which is why the 'MakePixelPerfect' code only executes when I'm fading in. Alternatively, you could replace the line that begins "if (overlayGUI != ..." with an appropriate check for your own flag if you like.

Jodon

  • Guest
Re: UITexture not displaying until transform is repositioned
« Reply #9 on: November 28, 2013, 07:13:44 PM »
I'm running into this issue right now.  I don't think it's UITexture related, instead it's probably related to UIDraggablePanel (at least in my case).  It seems that the UIDraggablePanel somehow interferes with clipping, causing the "checkbox" to not appear until its like 3rd or 4th time clicking it.  There are some changes to dragging in 3.0.6 so I hope this is addressed.  Really odd -- it only works 100% if I disable UIDraggablePanel.

Just to update this issue, 3.0.6f6 does not solve this issue.  I had ameliorated the issue slightly by commenting out the code in UIDraggablePanel that updates the clipRange and localPosition, right by the comment "Ensure that we're working with whole numbers..."  But it didn't completely solve it.

matdru

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: UITexture not displaying until transform is repositioned
« Reply #10 on: December 04, 2013, 08:20:05 AM »
Just to update this issue, 3.0.6f6 does not solve this issue.

Same from me, i had to modify UITweener so that it forces the sprites to be PixelPerfect, it works but is not very performance friendly, I'd love to see it fixed in next release.

PS. Thanks hummada23 for hints!

AGB

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 74
    • View Profile
    • Steam Defense
Re: UITexture not displaying until transform is repositioned
« Reply #11 on: December 04, 2013, 08:34:52 AM »
I'm a busy man... I have places to go,monsters to kill...

hummada23

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 45
    • View Profile
Re: UITexture not displaying until transform is repositioned
« Reply #12 on: December 08, 2013, 07:38:29 PM »
I don't think so- I haven't actually checked this, but didn't ArenMook add the linked functionality in the latest NGUI version? (and yet the problem still occurs in the latest version of NGUI)

matdru

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: UITexture not displaying until transform is repositioned
« Reply #13 on: January 10, 2014, 06:15:43 AM »
Hi, just wanted to up this issue because as of the latest update the issue is still here, but our temporary fix is no longer viable because of the changes in the code, and i've seen some people creating new posts/threads about the exact same issue so it will be good to make some noise about it :)

AGB

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 74
    • View Profile
    • Steam Defense
Re: UITexture not displaying until transform is repositioned
« Reply #14 on: January 10, 2014, 06:43:27 AM »
Yup, problem is still there even in 3.0.8f7 :( Usually im getting it, when adding prefab with texture in uiPanel.
I'm a busy man... I have places to go,monsters to kill...