Author Topic: Slow frames when enabling panels with many widgets  (Read 11523 times)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Slow frames when enabling panels with many widgets
« Reply #15 on: May 21, 2014, 05:26:21 PM »
How so?

Widget
- Scroll View
-- Panel (constrained)
--- Sprite

Set widget alpha to 0, hit Play, move widget alpha to 1 -- it's visible. Use TweenAlpha instead -- same, it's visible.

helmesjo

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 116
    • View Profile
Re: Slow frames when enabling panels with many widgets
« Reply #16 on: May 21, 2014, 05:35:17 PM »
How so?

Widget
- Scroll View
-- Panel (constrained)
--- Sprite

Set widget alpha to 0, hit Play, move widget alpha to 1 -- it's visible. Use TweenAlpha instead -- same, it's visible.

Hmm... Try this setup (which is pretty much exactly the same without the "noise"):

- Panel (constrained)
-- Widget A
--- Widget B
---- ScrollView horizontal (clipped)
----- ScrollView vertical (constrained)
------ Sprites & Labels

Set alpha of the Widget A to 0 in Awake (i do it in another component than UIWidget, if that matters when you debug), then back to 1 (again, done from script but that shouldn't matter.

Sorry, don't have time to create a repo atm but that is the current hierarchy.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Slow frames when enabling panels with many widgets
« Reply #17 on: May 21, 2014, 05:54:10 PM »
Right off the bat, Awake is the wrong place for this. Awake should only set properties of the script you're executing it from. It should never be used to alter values of other scripts. Use Start for that.

helmesjo

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 116
    • View Profile
Re: Slow frames when enabling panels with many widgets
« Reply #18 on: May 21, 2014, 05:56:55 PM »
Right off the bat, Awake is the wrong place for this. Awake should only set properties of the script you're executing it from. It should never be used to alter values of other scripts. Use Start for that.

Hehe, kinda embarrassing I said it since I'm kinda hitler around here about just that... But just double-checked and it was actually Start()!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Slow frames when enabling panels with many widgets
« Reply #19 on: May 21, 2014, 09:41:31 PM »
No difference trying your hierarchy.
  1. using UnityEngine;
  2.  
  3. public class Test : MonoBehaviour
  4. {
  5.         void Start ()
  6.         {
  7.                 GetComponent<UIWidget>().alpha = 0f;
  8.                 GetComponent<UIWidget>().alpha = 1f;
  9.         }
  10. }

helmesjo

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 116
    • View Profile
Re: Slow frames when enabling panels with many widgets
« Reply #20 on: May 22, 2014, 01:38:44 AM »
No difference trying your hierarchy.
  1. using UnityEngine;
  2.  
  3. public class Test : MonoBehaviour
  4. {
  5.         void Start ()
  6.         {
  7.                 GetComponent<UIWidget>().alpha = 0f;
  8.                 GetComponent<UIWidget>().alpha = 1f;
  9.         }
  10. }

Well you should set it back to 1 "later on". That's maybe a little vague, but what I have is basically a set of screens, which set the Widget.alpha =0f; in start (this is in a custom component but on the actual "screen"-object) if they are not the "initial screen". Then, "later on" when I want to navigate to one of the other screens, I set the toScreen.alpha = 1f; and tween it in (and set fromScreen.alpha = 0f; when it's not visible anymore). In the example above, the hierarchy was for "toScreen". Makes sense?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Slow frames when enabling panels with many widgets
« Reply #21 on: May 22, 2014, 03:43:19 PM »
Unfortunately I can't reproduce this on my end from your descriptions, so I will need a repro case to have a look at.

helmesjo

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 116
    • View Profile
Re: Slow frames when enabling panels with many widgets
« Reply #22 on: May 22, 2014, 03:44:37 PM »
Unfortunately I can't reproduce this on my end from your descriptions, so I will need a repro case to have a look at.

Alright, I'll try to put up a repro as soon as I've got the time!