I’m on the close to last steps of the tank tutorial and my camera doesn’t work due to a URP prefab which can’t go with the camera which isn’t URP the problem is that in the entire tutorial URP was a issue with many aspect of the tutorial including rendering of asset from the asset shop and now the code shows an error (NullReferenceException: Object reference not set to an instance of an object
UnityEngine.Rendering.Universal.UniversalAdditionalCameraData.get_cameraStack () (at ./Library/PackageCache/com.unity.render-pipelines.universal@f70afd0d2146/Runtime/UniversalAdditionalCameraData.cs:589)
Tanks.Complete.GameUIHandler.Awake () (at Assets/_Tanks/Scripts/UI/GameUIHandler.cs:43)) so I was wondering if anyone else seen this issue and nows how to fix it
- Often when using asset store assets with URP use the render pipeline converter to convert the materials
- Share the code from the GameUIHandler, as it calls something in URP
- Make sure Unity is updated
Well first go find what is on that line, what is null. Is it even related to URP or anything even renderer-related?
Remember… The answer is always the same… ALWAYS!
How to fix a NullReferenceException error
Three steps to success:
- Identify what is null ← any other action taken before this step is WASTED TIME
- Identify why it is null
- Fix that
NullReference is the single most common error while programming. Fixing it is always the same.
Some notes on how to fix a NullReferenceException error in Unity3D:
line 43
<if (!data.cameraStack.Contains(cam)) >
mean that the null is present in the camera slot not working due to UPR
1: turns all textures violet so doesn’t work
2:see post below as that has the problematic script
3: I download after latest update
I seem to recall in a different thread that you fixed some materials in your project by switching them to the “Standard” shader. The Standard shader shouldn’t even work in URP. It sounds like maybe you are not actually using URP. When you open the graphics settings for your project, do you have a pipeline asset assigned?
This was the easy fix for me. Thanks!