vrchat-community / ClientSim

Client Simulator for World Building
https://clientsim.docs.vrchat.com
Other
237 stars 24 forks source link

[1.2.2] LineRenderer.BakeMesh failing unexpectedly #49

Open techanon opened 2 years ago

techanon commented 2 years ago

When trying to create a mesh from a LineRenderer, in ClientSim the behavior is crashing upon calling line.BakeMesh(mesh, true);. This call works fine in-game via build and test. I think CS is trying to force use the 3 param override BakeMesh(Mesh, Camera, bool) instead of the 2 param method because the failure mentions Camera being null: image

Hunterk1241 commented 1 year ago

I have been having the same issue when working with QVPen. At first, I thought it broke on my end, but it turned out to just be ClientSim. Definitely an issue!

kaikoga commented 1 year ago

This is because 2 param overload of LineRenderer.BakeMesh(Mesh, bool) internally references Camera.main, which does not exist in ClientSim because no active camera is tagged with MainCamera while ClientSim session.

I suppose overriding the tag of PlayerCamera object in Packages/com.vrchat.clientsim/Runtime/Resources/ClientSim/Prefabs/ClientSimPlayerLocal.prefab with MainCamera should fix this problem, which should have no side effects as long as Camera.main and GameObject.FindGameObjectWithTag("MainCamera") are not exposed to Udon, and LineRenderer.BakeMesh(Mesh, bool) is working in-game anyway.