Author Topic: Physics Simulate goes wild when localScale = 0  (Read 2611 times)

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Physics Simulate goes wild when localScale = 0
« on: June 26, 2014, 12:40:52 PM »
Very strange issue I'm having.

I have a bunch of NGUI panels that I am setting the scale to zero in order to keep them activated while "hiding" them from the user.  On the phone, when I ran the app, the FPS went from its normal 22-27 to 2-7 fps.  Using the profiler, found that Physics Simulate is eating up the FPS.  After testing,  I found that  having the panels at zero scale was the problem. 

Questions:

1. Why is the physics simulate going wild when the scale is zero?
2. Is there another way to hide the panels without disabling them?  Reason is that I'm using PoolManager to populate SVs, if the SV is not active then PM doesn't see the already spawned items and keeps on spawning new ones. 


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Physics Simulate goes wild when localScale = 0
« Reply #1 on: June 26, 2014, 02:06:56 PM »
Because scale of zero is invalid. It causes division by zero, which is a NaN.

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Re: Physics Simulate goes wild when localScale = 0
« Reply #2 on: June 27, 2014, 04:08:46 AM »
So what would be the best way to hide something and still make it active.

Would you set the localScale to .0001 ?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Physics Simulate goes wild when localScale = 0
« Reply #3 on: June 27, 2014, 04:59:16 AM »
You can move them out of the way, to some pre-defined "out of the screen" place instead of scaling them down. That's generally what I'd do, since moving a panel is cheap.

Of course, that would mess with things if you have anchors on individual widgets inside that panel that anchor to the screen. I believe if you anchor to a panel without a clip region, it will default to screen size - but I'm not 100 % if that includes position or just size.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Physics Simulate goes wild when localScale = 0
« Reply #4 on: June 27, 2014, 12:27:26 PM »
When I scale something, I don't let it go below 0.01. Due to the low scale of UIRoot, using another small scale value is not advised. Also when you're tweening something from 1 to 0.01, you will not notice any difference between that and 1 to 0.0001, unless you do it very, very slowly.