[VRCCameraSettings] Property to tell which camera is currently rendering
available in future release
aurycat
Within a render callback such as OnWillRenderObject, it's useful to be able to check which camera is rendering. Unity has "Camera.current" for this, but it's not exposed to Udon.
The new camera API is awesome, but without a property like that, I still can't make my UdonPortals prefab render correctly in the hand-held camera because there's no way to tell which camera is currently triggering OnWillRenderObject.
I'd like a property to tell which camera is responsible for the render. A really simple implementation would be a new read-only property like:
- VRCCameraSettings.CurrentCameraType: An enum consisting of the values "ScreenCamera" or "PhotoCamera".
However, I think this API could be extended further to be even more useful. In particular, if a Camera that was created by the world (and so is already accessible to Udon) is rendering, it would be great to be able to access the actual Camera object! Just like Unity's "Camera.current", but only limited to world-created Cameras. An API might look like this:
- VRCCameraSettings.CurrentCameraType: Enum consisting of the values "ScreenCamera", "PhotoCamera", "WorldCamera", or "Other". "WorldCamera" would be any camera created by the current world, i.e. a Camera that's accessible to Udon. "Other" would be anything else that isn't (yet!) accessible to Udon, e.g. avatar cameras or the screenshot camera.
- VRCCameraSettings.CurrentCamera: A reference to the current Camera object, just like Unity's Camera.current, except it's only set when CurrentCameraType is "WorldCamera". Otherwise, it's null.
Log In
This post was marked as
available in future release
aurycat
Yeah, having a CurrentCameraPosition / CurrentCameraRotation even for non-exposed cameras would be awesome because it means it would be trivial to make camera-dependent stuff in OnWillRenderObject for any cameras, be they avatar, drone, mirror, etc.
Of course, a simple Position and Rotation only works for non-stereo cameras, so you'd still need some extra code to handle the main player stereo camera differently. (I
think
we can assume the only stereo camera is the main player camera? I think even VRC mirror cameras are two separate cameras.)BobyStar
It would be nice as well if it included a basic Position and Rotation value (or a read only copy like the current VRCCameraSettings values give) for the non-exposed cameras. Like for avatar cameras so custom scripted "billboard" behavior (that can't be replicated with shader due to dynamic hierarchy like a UI Canvas).
_
_tau_
tracked
I like the proposed API design a lot! If it's possible I may copy it just like that.