0

I have a single canvas, in which lives a global UI image background, and 4 frame objects. In each frame object, there lives up to hundreds of UI images and texts. No buttons and no colliders exist in a frame object.

During the game, scripts lerp the frames by setting "frame.transform.localPosition". When all 4 frame objects are stationary, the frame rate is a constant 60fps. When a frame is in motion, the fps falls to about 33 fps and pops back up as soon as the movement is done.

The profiler suggests the canvas is doing a huge amount of work. What is going on? Are UI elements in a canvas supposed to be static?

Picture of my scene: http://i.imgur.com/o3pfAt3.png

Tyler
  • 3
  • 2
  • 1
    what is a "frame"? what are you referring to ? – Fattie Jul 22 '16 at 17:56
  • also what is " frame is in motion"? – Sourav Paul Roman Jul 22 '16 at 18:02
  • A frame object is just an object that is filled with UI elements. It looks like a picture frame. I used a poor word choice. – Tyler Jul 22 '16 at 18:06
  • what is an "object"?? using the Unity documentation, show the actual class (or whatever?) you are talking about. Random example, do you mean this: https://docs.unity3d.com/ScriptReference/UI.Text.html say ?? – Fattie Jul 22 '16 at 18:08
  • in any event, I've explained the problem below .. you have to use the anchored position concept to move UI elements. you **cannot** (generally) just move the transform around, it's meaningless. – Fattie Jul 22 '16 at 18:10

1 Answers1

0

If what you are doing is what I think you are doing, you don't want a single canvas with the 4 frames inside of it, what you should be doing is having 4 canvases each being a child of one of the frame objects which you move around.

From the "Tanks" tutorial from unity, see the video on Tank Health. In that video they create a health bar that follows the tank around, I believe this is a similar effect to what you are trying to do with your frames and children of them.

Scott Chamberlain
  • 124,994
  • 33
  • 282
  • 431