How the Check Works
The CheckPerformanceOptimization
is designed to identify and report potential performance optimization suggestions within scripts. This check helps developers identify common performance pitfalls and suggests improvements.
The check operates at the MonoScript level:
- MonoScript Level: When invoked on a
MonoScript
, it analyzes the script’s text line by line, checking for various performance-related patterns within the code.
The check performs the following steps:
- Method Detection: It detects the start of common update methods such as “Update,” “LateUpdate,” and “FixedUpdate” to focus on performance-related checks within these methods.
- Line Iteration: It iterates through each line of the script, checking for specific patterns related to common performance pitfalls.
- Performance Checks: For each identified pattern, the check logs an issue with a description indicating the performance suggestion and references the line number and the script.
- User Configuration: The check can be configured through the Unity Editor, allowing users to enable or disable specific performance checks based on their preferences.
When to Use This Check
- Performance Optimization: Identify and address potential performance issues in your scripts, enhancing the overall performance of your Unity project.
- Best Practices Adherence: Ensure adherence to performance best practices by leveraging suggestions provided by the check.
How to Use the Check
- Configure Checks: Use the Unity Editor to configure which performance checks you want to enable or disable based on your project requirements.
- Perform Check: Initiate the check via the Verification Window by selecting the MonoScripts you want to analyze for performance optimization suggestions.
Methods
PerformCheck(MonoScript script)
: Initiates the verification process for a specific MonoScript. It analyzes the script’s text for various performance-related patterns and logs issues accordingly.
DrawSpecificProfileEditor()
: Provides a custom editor interface in the Unity Editor, allowing users to configure which specific performance checks to enable or disable.
Attributes
description
: Provides a short description of what this check does, highlighting its purpose in identifying potential performance optimization suggestions within scripts.
longDescription
: Offers a more detailed explanation of the check, providing additional context on how it analyzes and reports performance-related issues within MonoScripts.