Search Issue Tracker
By Design
Votes
1
Found in
2019.2.19f1
2019.3
2020.1
Issue ID
1216808
Regression
No
SetCameraCullingPlane() does not modify the Plane index
How to reproduce:
1. Open the attached (CameraProperties.zip) project
2. Open the "SampleScene" Scene
3. Enter the Playmode -> see the debug.log in Console Window -> Exit Playmode
4. Select "Main Camera" in Hierarchy -> In Scene Window move the Camera
5. Enter Play Mode
Expected result: SetCameraCullingPlane() output in the Debug.log is different than it was before moving Camera
Actual result: SetCameraCullingPlane() output in the Debug.log is the same as it was before moving Camera (see CameraProperties repro.mp4)
Reproducible with: 2019.3.2f1, 2020.1.0a23
Notes:
- SetShadowCullingPlane() appears to not work as intended too
- Could not test on 2018.4 because of errors on the Script
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Out-of-bounds memory access with multiple CanvasRenderers under a Canvas when using Mesh API
- Inspector tries to access file after it was deleted when the file was locked in Inspector window
- Changing Transform values in Search window Inspector loses focus while dragging and stopping mouse without releasing dragging action
- Saving changes on the dirty VFX Graph during the Play mode throws "The referenced script (Unknown) on this Behaviour is missing!" warnings
- VFX Graph Debug Info overlaps the "Initialize" block debug info by default
Resolution Note:
The described issue arises from how structs work in C# (they are value type). Both ScriptableCullingParameters and CameraProperties are structs. CameraProperties is accessed through a public property on the ScriptableCullingParameters. To get the expected behavior you thus have to write the properties back;
void DemonstrateApproach()
{
Camera.main.TryGetCullingParameters(out ScriptableCullingParameters p);
Debug.Log($"before: {p.cameraProperties.GetCameraCullingPlane(0).normal}"); // prints before: (0.7, 0.0, 0.7)
var properties = p.cameraProperties;
properties.SetCameraCullingPlane(0, new Plane(Vector3.up, Vector3.zero));
p.cameraProperties = properties;
Debug.Log($"after: {p.cameraProperties.GetCameraCullingPlane(0).normal}"); // prints after: (0.0, 1.0, 0.0)
}
Many IDEs such as Resharper will highlight issues like this. In case you want to know more about the details consider reading this page; https://stackoverflow.com/questions/34906823/c-sharp-getters-setters-in-structs-and-interfaces