This PR caches Camera.main within the NeuroUtilities class.
As you probably know, Unity's Camera.main calls FindGameObjectsWithTag("MainCamera") internally and does not cache it, which causes small but unnecessary CPU overhead, especially when called frequently This was improved drastically as of 2020.2, but still is almost the same as calling GetComponent. Currently, the project calls this upwards of 180 times in Visibility.IsVisible and every frame when the fake Cursor is on screen. While not very noticeable framewise, caching the main camera is recommended by Unity themselves and again relieves slight CPU overhead.
This PR caches Camera.main within the NeuroUtilities class.
As you probably know,
Unity'sThis was improved drastically as of 2020.2, but still is almost the same as callingCamera.main
callsFindGameObjectsWithTag("MainCamera")
internally and does not cache it, which causes small but unnecessary CPU overhead, especially when called frequentlyGetComponent.
Currently, the project calls this upwards of 180 times in Visibility.IsVisible and every frame when the fake Cursor is on screen. While not very noticeable framewise, caching the main camera is recommended by Unity themselves and again relieves slight CPU overhead.