Skip to content

RootObjectValidators

Leon Kirschbaum edited this page Nov 12, 2022 · 13 revisions

RootObjectValidators

RootObjectValidators are great for validating Unity objects such as ScriptableObjects, Materials and Components, as you only get a warning / error message for the object itself which is called the root. Unlike the ValueValidator referencing a root object inside another object will not throw an additional warning / error.

Currently Available RootObjectValidators

AnimationValidator

How Does This Validator Work?

The Animation Validator checks all objects, which are under a Canvas and have the Animation component attached. The fix disables the Animation component and suggests to use a Tweener like Dotween. Additionally it opens the website of Dotween in your browser so the user can get started right away. In the future I want to change it from enabling to destroying that component.

Why Does This Improve Performance?

Using Unitys Animators will dirty the canvas every frame, even if the value in the animation does not change. Therefore it reduces the redraw calls of the canvas.

For more information regarding the use of Unity Animators on UI click here.

AnimatorValidator

How Does This Validator Work?

The Animator Validator checks all objects, which are under a Canvas and have the Animator component attached. The fix disables the Animator component and suggests to use a Tweener like Dotween. Additionally it opens the website of Dotween in your browser so the user can get started right away. In the future I want to change it from enabling to destroying that component.

Why Does This Improve Performance?

Using Unitys Animators will dirty the canvas every frame, even if the value in the animation does not change. Therefore it reduces the redraw calls of the canvas.

For more information regarding the use of Unity Animators on UI click here.

CanvasValidator

How Does This Validator Work?

The Canvas Validator checks all objects, which have the Canvas component attached. It checks if the Pixel Perfect feature is enabled and if the Camera field is empty. The fix will disable the Pixel Perfect feature and the user can assign a Camera to the Canvas in the Validator window.

Why Does This Improve Performance?

By having Pixel Perfect enabled the Canvas rebuilds all the time and leaving the Camera field empty will cause Unity to call Camera.main, which is heavily taxing the performance.

ChildCountValidator

How Does This Validator Work?

The Child Count Validator checks all GameObjects, which have more children than the Child Count Limit (default 50), which can be modified and notifies the user that by decreasing the child count the performances increases. If the child count is intended or unavoidable it suggests to use Object Pooling for better performance.

Why Does This Improve Performance?

By having less GameObjects to render the performance increases. Object Pooling helps with the rendering of many GameObjects while still being performant.

For more information about Object Pooling click here.

ImageValidator

How Does This Validator Work?

The Image Validator checks all GameObjects, that have the Image component attached. It checks if Raycast Target is enabled and if Use Sprite Mesh is disabled. The fix disables the Raycast Target and enables Use Sprite Mesh.

Why Does This Improve Performance?

Having Raycast Target enabled will cause the Graphic Raycaster to perform intersection checks every frame for all elements that have Raycast Target enabled. Disabling this will improve performance, since they are removed from the list of elements that are checked every frame. If the Mesh Type is Full-Rect, Unity will render the sprite as a full quad with transparent regions. Using the Mesh Type Tight will eliminate the transparent regions thus you render fewer pixel. To use this the Image Type must be set to Simple and Use Sprite Mesh must be enabled.

For more information about Sprite Mesh Types click here.

OutlineValidator

How Does This Validator Work?

The Outline Validator checks all GameObjects, that have the Outline component attached. Currently it checks if it's enabled and the fix just disables it. In the future I want to change it from enabling to destroying that component.

Why Does This Improve Performance?

It constantly dirties the Canvas, since the Outline is calculated every frame - very performant taxing!


ShadowValidator

How Does This Validator Work?

The Shadow Validator checks all GameObjects, that have the Shadow component attached. Currently it checks if it's enabled and the fix just disables it. In the future I want to change it from enabling to destroying that component.

Why Does This Improve Performance?

It constantly dirties the Canvas, since the Shadow is calculated every frame - very performant taxing!

TextMeshProUGUIValidator

How Does This Validator Work?

The Text (TMP) Validator checks all GameObjects, that have the TextMeshProUGUI component attached. It checks if Raycast Target is enabled or not, the use of Auto Size feature and which Shader is being used. The fix disables the Raycast Target, unchecks the Auto Size feature and currently changes the Shader in the Material to a more performant Shader. In the future I want to let the user to decide which Shader will be used.

Why Does This Improve Performance?

Having Raycast Target enabled will cause the Graphic Raycaster to perform intersection checks every frame for all elements that have Raycast Target enabled. Disabling this will improve performance, since they are removed from the list of elements that are checked every frame. Using the Auto Size feature will constantly change your UI, which dirties your Canvas, leading to a Redrawing of the Canvas. This heavily taxes the performance so always disable it. Changing from the Desktop Version of TextMeshPros SDF Shader to the Mobile version increases the performance, since the Mobile versions are less demanding but also support less effects.

For more information about TextMeshPro click here.

TextValidator

How Does This Validator Work?

The Text (Legacy) Validator does the same as the Text (TMP) Validator but only for GameObjects, that have the Legacy Text component attached. It checks if Raycast Target is enabled or not and the use of the Best Fit feature. The fix disables the Raycast Target and unchecks the Best Fit feature.

Why Does This Improve Performance?

Having Raycast Target enabled will cause the Graphic Raycaster to perform intersection checks every frame for all elements that have Raycast Target enabled. Disabling this will improve performance, since they are removed from the list of elements that are checked every frame. Using the Best Fit feature will constantly change your UI, which dirties your Canvas, leading to a Redrawing of the Canvas. This heavily taxes the performance so always disable it.

Clone this wiki locally