- Home /
Better way to make big 2D Game. UI Canvas, Transform calculation, animation
Hello everybody,
I saw some strange performance behavior in the profiler, i would like to know how the engine works.
I have few questions about making big 2D games with unity.
How unity calculates Transform and moving objects within the UI Canvas ?
Human animation doesn't have its place into UI Canvas, does it lead to over calculation ?
I've taken some screenshots to help you understanding the structure of my 2D game.
On the first screenshot, you can see the hierarchy,
I've a Canvas (CanvasUI) containing all buttons, menus, user interfaces.
And another Canvas (CanvasGame) containing the game and dynamic objects of the game like environment, human entities, lot of animations and transform translation.
The second screenshot shows the strange behavior noticed in the profiler, You can see the frame with the environment moving and the frame without the environment moving.
The EnityBehavior script is used to move RectTransform of human entities, each entites has an AnimatorController.
The LookHero script is used to translate the environment, with the aim of centering the view on the hero. ('Environment' as you can see in the first screenshot)
The EventSystem takes also a lot of perfomance, although the game canvas doesn't really need events. (Maybe i could disable event only for this canvas)
What are you thinking about my game structure?
In conclusion i think, i will replace the CanvasGame by SpriteRenderer system but it is a lot of refactor. I prefer to ask you before doing anything
PS: sorry for my english writting, i'm french native