I have imported models from blender into Unity, also checked generate lightmap UV's in the import settings.

Then I set the model as static and baked the scene. After that when the object is disappearing because of the Occlusion I get an Error:

NullReferenceException: Object reference not set to an instance of an object UnityEngine.PostProcessing.BuiltinDebugViewsComponent.GetCameraEvent () (at Assets/PostProcessing/Runtime/Components/BuiltinDebugViewsComponent.cs:137) UnityEngine.PostProcessing.PostProcessingBehaviour.TryExecuteCommandBuffer[BuiltinDebugViewsModel] (UnityEngine.PostProcessing.PostProcessingComponentCommandBuffer`1 component) (at Assets/PostProcessing/Runtime/PostProcessingBehaviour.cs:444) UnityEngine.PostProcessing.PostProcessingBehaviour.OnPreRender () (at Assets/PostProcessing/Runtime/PostProcessingBehaviour.cs:166) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

If I double click on the Error it brings up the Script named:


and shows the error on the following line 137:

    public override CameraEvent GetCameraEvent()
            return model.settings.mode == Mode.MotionVectors
               ? CameraEvent.BeforeImageEffects
               : CameraEvent.BeforeImageEffectsOpaque;

Well this might be a easy question but how do I check if the var model != null to workaround the error, I found out that this error occurs in the older versions of Unity.

I tried putting if(model != null) above the line but that gives me also a error, could someone help me on this?

  • \$\begingroup\$ "I tried putting if(model != null) above the line but that gives me also a error" cool! Show us what you tried and what specific error you got. \$\endgroup\$ – DMGregory Apr 7 at 13:38
  • \$\begingroup\$ if I do the if(model != null) above the line I get this error: Assets/PostProcessing/Runtime/Components/BuiltinDebugViewsComponent.cs(103,13): error CS0161: `UnityEngine.PostProcessing.BuiltinDebugViewsComponent.active.get': not all code paths return a value The "get" isn't returning now why is this and what can I do? \$\endgroup\$ – Daniel Apr 7 at 14:21
  • \$\begingroup\$ That error tells you that you need to provide a return value for that case, like if(model == null) return false; \$\endgroup\$ – DMGregory Apr 7 at 14:26
  • \$\begingroup\$ well it solved the first one now it moved to another function: I will edit my thread look it up there \$\endgroup\$ – Daniel Apr 7 at 14:29
  • \$\begingroup\$ It sounds like the scripts you're using are strongly expecting that the objects you're using them with should not be null. Rather than plug all the holes one by one, it might be better to investigate why they assume it will be non-null, and what's breaking that assumption. \$\endgroup\$ – DMGregory Apr 7 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.