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
- “Remove Unused Overrides” available on not loaded Scene and throws “ArgumentException: The scene is not loaded” warning
- Adaptive Probe Volume occlusion edge is calculated incorrectly when viewing probes near geometry edges
- Sampling a texture using an HLSL file throws shader errors and the code does not compile
- WebGL sends wrong value with large numbers when SendMessage function is used
- Add Behaviour dropdown has a part in which the dropdown outline is cut out when the Add Behaviour dropdown is opened
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