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
- Mono Windows Builds don't produce full log callstacks when generating logs
- AssetBundles fail to load when running in Built Players for Mobile Devices
- UI elements with text gets bigger and grey when Player window is moved to another screen with different resolution
- System name accepts multiline text but crops it on confirmation, duplicates input, and shrinks the field when empty
- UI element scale and position are wrong in project build when DRS is changed with HDR and Software Dynamic Resolution enabled
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