OnBecameInvisible, OnBecameVisible, broken
tracked
indominablerexx
Seems that the methods
OnBecameInvisible, OnBecameVisible
Are broken. I tested using a monoscript and they trigger properly, but they don't trigger using Udon.
Regular practices were followed in the testing, e.g.
-Object has a meshrenderer
-Has a standard shader (nothing funky)
- Scene camera is not messing with the results (closed the tab)
- No other cameras looking at it. Only camera being tested is the main camera
- Set normal callbacks as usual (using UdonSharp)
- Exact same code, except using Monoscript, works properly
- OnWillRenderObject DOES work however.
-> Using Udon 2020.06.16.20.53_Public.
Log In
This post was marked as
tracked
Fairplex
I've made a PR so they can be at least documented in U# docs:
Fairplex
I dont want to be pushy, but is there a reason for not listing and documenting those methods? I can't believe it's that hard since those are already working in VRChat.
Fairplex
Bump
I believe that these methods are essential for content optimization.
As Nestorboy pointed out, we can actually utilize these events in VRChat with _onBecameVisible or _onBecameInvisible. Shouldn't they be recognized and documented so that more people can become aware of and use them in their code?
Nestorboy
After some digging, I came to the conclusion that these events are actually available in Udon, but neither U# or Udon Graph seem to recognize them. There are also a handful of other events which aren't properly listed/recognized, and they aren't even documented anywhere. I'm not entirely sure how long these events have been around for, but they're at least available in the latest version of the SDK.
In order to use the OnBecameVisible/Invisible events right now, you can do the following:
Udon Graph:
Add a Custom Event node, and name the event _onBecameVisible or _onBecameInvisible.
UdonSharp:
Add a public void method with no parameters and call it either _onBecameVisible or _onBecameInvisible.
Cake․
I tested this in VRCSDK3 2021.06.03.14.57 and can confirm that this is still broken.
While I was able to trigger the events in play mode (using U# and CyanEmu), they did not trigger in VRChat.
indominablerexx
Current workaround:
- Set a render bool to false.
- In Start(), set a global render variable. GetComponent<Renderer>();
- In OnWillRenderObject(), if render bool is false, set it to true.
- In Update(), if render bool is true, check if renderer.isVisible, if not visible, set render bool to false