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
- [Android] Stage information is not logged when Log Shader Compilation is enabled
- [Vulkan] The memory allocation increases rapidly when there are multiple (three or more) Real-Time Reflection Probes in the Scene
- [macOS] Library folder of the opened project can be deleted which leads to the crash
- “Default Scene” dropdown field contains a spelling mistake “Default Builtin”
- Editor crashes on PPtr<Mesh> after adding Text Mesh and Cloth Components to the same GameObject
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