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
- Fixing Message Loss in UMPE During Domain Reload
- The Editor freezes when ScheduleReadOnly of IJobParallelForTransform with dependency is used
- Text is truncated in the Inspector when the display scale is set to 150%
- CancellationTokenSource(<timeout>) has incorrect cancellation status when used in WebGL Player
- VFX property value names are cut off when properties with 'Arc' are viewed in the VFX Blackboard
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