keijiro / Pcx

Point cloud importer & renderer for Unity
The Unlicense
1.36k stars 197 forks source link

NullReferenceException with ComputeBuffer and Disc shader using Universal Render Pipeline (URP) #59

Open bjornsyse opened 4 years ago

bjornsyse commented 4 years ago

Hi, I get this error when using Universal Render Pipeline and the ComputerBuffer type of rendering.

Discs show up in editor, but not in Game view and this error is thrown

NullReferenceException: Object reference not set to an instance of an object
Pcx.PointCloudRenderer.OnRenderObject () (at Library/PackageCache/jp.keijiro.pcx@1.0.0/Runtime/PointCloudRenderer.cs:88)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
roblms commented 3 years ago

Same problem here, using Unity 2020.2.2f1, Universal RP 10.2.2.

The issue appears to be this line

var camera = Camera.current;

modifying it to use Camera.main appears to solve the issue.

smokelore commented 3 years ago

@keijiro is setting var camera = Camera.main the correct solution here? I am running into the same problem.

Angratharr commented 2 years ago

I have this same issue and tried modifying the PointCloudRenderer script to the above suggestion. However, the change reverts back because the package gets revalidated (I think).

here is the warning: The package cache was invalidated and rebuilt because the following immutable asset(s) were unexpectedly altered: Packages/jp.keijiro.pcx/Runtime/PointCloudRenderer.cs

How can I apply this fix?