It is full offline installer standalone setup of PVS-Studio 2021 Free Download. Further, we get information about the camera with the help of this variable instead of calling 'GetComponent'.PVS-Studio 2021 Free Download Latest Version for Windows. The return value of this method is written to the 'camera' variable. If we want to avoid multiple execution of the expensive operation, we can write the result of 'GetComponent' to the variable. 'ProcessCamera' is used in the 'Update' method, which is a frequently called method. Each time the 'ProcessCamera' method is called, the 'GetComponent' method is executed four times. This method searches for the object of the 'Camera' type. We get the camera by calling 'GetComponent'. The information about the camera is written to the 'ProcessCamera' method. Var cameraEvent = GetComponent().eventMask Take a look at another example: public void Update() Then this variable is used instead of the 'Camera.main' property to handle the camera. The value of this property is assigned to the 'camera' variable. In this case, 'Camera.main' is accessed once. We can avoid accessing the 'Camera.main' property multiple times by writing its value into a variable. As a result, the expensive operation is performed on each loop iteration. When the 'Camera.main' property is accessed, a cache lookup is performed, which overloads a CPU. The camera is handled in the 'Update' method. Take a look at this example: public void Update()įoreach (var cameraHandler in CameraHandlers) If we access these properties and methods frequently, this can lead to decreased performance. The PVS-Studio analyzer has detected that the frequently executed code contains accesses to expensive properties or methods.Īccording to the Unity documentation, when some methods and properties from the Unity API are accessed, they perform expensive operations.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |