Author Topic: Invisible sprites in 3.8.0 and earlier on mobile devices  (Read 2770 times)

ClockStone_Helmut

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Invisible sprites in 3.8.0 and earlier on mobile devices
« on: February 26, 2015, 12:25:55 PM »
For an estimated 6 months now we are having problems with invisible sprites.
Likely the UIPanel does not refresh correctly

The problem most notably appears on slow devices that are prone to frame rate hiccups and might have low memory.
Examples would be the iPhone4 and the Nexus S.
On new and fast devices we hardly ever have the problem, if at all.

Things that we use in problematic cases might cause it individually (just a listing, no order implied)

  • Enabling a GameObject hierarchy below a UIPanel (i.e. a child branch of the UIPanel becomes active)
  • Scaling a sprite Transform up from zero scale as a fade-in with a Unity keyframe animation (we don't use ActiveAnimation.Play, instead we manually sample with UnityEngine.Animation)
  • Moving a sprite Transform from off-screen into view (we verified that HideIfOffScreen=false everywhere) with a Unity keyframe animation
  • Re-parenting a pooled GameObject into a UIPanel hierarchy
  • Probably other causes


Maybe 1. is a necessary condition for all the other cases, because we make extensive use of it, and it might be involved in all problematic cases.

The problem occurs randomly.
When it happens it makes a random selection of sprites invisible. Not always the same sprites, even in the same application execution.

* We also sometimes had invisible sprites inside the Editor that would become visible after manually disabling/enabling it.
* We also had problems with grid items not getting a layout, e.g. they would all remain in the same spot. (we only add objects directly to the hierarchy, and don't use any NGUI helper methods)

Might also be related to
http://www.tasharen.com/forum/index.php?topic=6705.msg57463#msg57463

Apparently it can be fixed by calling UIPanel.Refresh after activating branches in the hierarchy. At least it seems to fix it for now.

Using Unity 4.6.1f1 with pro licenses for mobile and Editor.

Is this expected behaviour, or should it just work?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Invisible sprites in 3.8.0 and earlier on mobile devices
« Reply #1 on: February 27, 2015, 04:52:04 AM »
Scale of zero is invalid. You can't divide by zero, so it's not possible to calculate the inverse of its transform. You should never scale to zero. Use a small value instead like 0.01.

After reparenting a UI element make sure to call its MarkParentAsChanged(). (you can also BroadcastMessage it).

ClockStone_Helmut

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Invisible sprites in 3.8.0 and earlier on mobile devices
« Reply #2 on: March 02, 2015, 03:26:57 AM »
Thank you for the quick answer.

We will definitely remove the zero scaling in the animation, as it is most likely the frame rate dependent problem.

Please feel free to mark this thread as resolved.