2d game
I’m trying to optimize performance.
The main idea is not to display objects outside the camera.
Objects can be complex, so OnBecameVisible is not always suitable.
There is a camera on my stage. In the camera I created a nested CameraView object with Rigidbody 2D Kinematics and Box Collider 2D isTrigger.
There is an object in my scene - JungleBatEnemy1.
This is the “enemy container”. It has Box Collider 2D isTrigger.
JungleBatEnemy1 contains a SkeletonCharacter object.
This is the enemy.
The SkeletonCharacter contains an EnemyTopBar object.
This is text with the name and description of the enemy.
As soon as the CameraView crosses JungleBatEnemy1, the SkeletonCharacter enemy object is activated. As soon as the object leaves the zone, the enemy SkeletonCharacter is deactivated.
Freeze and FPS drop occur when SkeletonCharacter (enemy) is activated. Let me remind you that there is a sign embedded in the enemy.
After the freeze, after a second the FPS becomes normal again.
It has been noticed that when the enemy sign is turned off, there are no friezes.
The profiler complains about the canvas, which is strange because… the enemy does not interact with the canvas in the game.
The text of the sign was made using 3D object → Text mesh pro.
And there is no canvas there either.
Help me understand why freezes and FPS drops occur?

