Component:MeshUVRaycastPortal: Difference between revisions

From Resonite Wiki
Added "also known as a raycast portal" So when user searches in the wiki for ray cast portal they get "MeshUVRaycastPortal" as a result
Replaced example with a more detailed example
 
Line 29: Line 29:


== Examples ==
== Examples ==
To set up this component, you will need a [[Component:Camera|camera]]. One can easily be made by creating a new camera through the [[Dev Tool]]'s "Create New" menu. The camera component on the newly created object can be put on a new slot and set to the side. The box collider needs to be replaced with a mesh collider. The mesh collider will automatically use the quad mesh on the camera. Now you are able to press buttons through the camera. It works way more consistently in orthographic mode.
In this example we will create a Camera, that looks at a Canvas, and a Quad that renders what the Camera sees.</br>
The <b>MeshUVRaycastPortal</b> will transfer the laser interactions from the Quad's MeshCollider to the Canvas, through the Camera.
 
1. Create New -> Object -> <i>Camera</i>
 
2. Spawn -> <code>resdb:///613cb78341d5b330aee559a1871011ccfb733221428ff9601ce56e19c7b1631e.brson</code> ( I will refer to it as <i>Checkbox</i>)</br>
* or from <b>Resonite Essentials</b> -> Examples -> UIX -> <i>Checkbox</i>
 
3. Place the <i>Checkbox</i> in front of the <i>Camera</i>
 
4. Create New -> 3D Model -> <i>Quad</i>
 
5. Create New -> Materials -> PBS Metallic (for example)
 
6. Set the Material as the Quad's Material
 
7. Grab the <i>RenderTextureProvider</i> from the <i>Camera</i>, and set it as this Material's MainTexture (AlbedoTexture)
 
8. Inspect the <i>Quad</i>, and add the <b>MeshUVRaycastPortal</b>
 
9. Set the <b>MeshUVRaycastPortal</b>'s Camera field to the <i>Camera</i> created by us
 
10. Now when you try to interact with the UI through the <i>Quad</i>, the UI should be responsive


== See Also ==
== See Also ==

Latest revision as of 10:40, 16 October 2025

This article or section is a stub. You can help the Resonite wiki by expanding it.
Component image 
Mesh UVRaycast Portal component as seen in the Scene Inspector

This component also known as a raycast portal allows users to interact with objects through a camera.

Usage

Fields
Name Type Description
persistent Bool Determines whether or not this item will be saved to the server.
UpdateOrder Int Controls the order in which this component is updated.
Enabled Bool Controls whether or not this component is enabled. Some components stop their functionality when this field is disabled, but some don't.
Offset Float How far back from the camera's actual view direction to project from
RayExit IUVToRayConverter Usually a camera
UVOffset Float2 The added offset to the UV point you hit on the mesh before it's projected out; best to keep this (0,0) unless needed
UVScale Float2 The multiplied offset to the UV point you hit on the mesh before it's projected out; best to keep this (1,1) unless needed
RepeatUV Bool Whether to repeat between the 0-1 range when the laser on the source hits a UV beyond 0-1
OverrideHitTriggers Nullable`1<Bool> Whether to hit colliders, requires Filter to have a sync delegate, but doesn't need to be enabled for this component to work
Filter delegate of identity Func`3<ICollider, Int, Bool> This is a field usually used by the dash manager in local space. Very hard to use, and is not required at all
FilterMode FilterCombineMode how to use the Filter if provided.

Behavior

  • The camera needs to be in orthographic mode for best results. it still works in perspective but because of perspective warping it only works well in the center. This component is used for the dash, but can be utilized in real world space, allowing for some interesting effects.
  • This component only works with mesh colliders. The type of mesh does not matter, since it uses the UVs; the mesh triangles have to determine what point on the camera output to project the raycast out of.
  • The mesh collider can only be a front sided collider for this component to work.
  • Only user interaction lasers are allowed to pass through, and only press button interactions.

Examples

In this example we will create a Camera, that looks at a Canvas, and a Quad that renders what the Camera sees.
The MeshUVRaycastPortal will transfer the laser interactions from the Quad's MeshCollider to the Canvas, through the Camera.

1. Create New -> Object -> Camera

2. Spawn -> resdb:///613cb78341d5b330aee559a1871011ccfb733221428ff9601ce56e19c7b1631e.brson ( I will refer to it as Checkbox)

  • or from Resonite Essentials -> Examples -> UIX -> Checkbox

3. Place the Checkbox in front of the Camera

4. Create New -> 3D Model -> Quad

5. Create New -> Materials -> PBS Metallic (for example)

6. Set the Material as the Quad's Material

7. Grab the RenderTextureProvider from the Camera, and set it as this Material's MainTexture (AlbedoTexture)

8. Inspect the Quad, and add the MeshUVRaycastPortal

9. Set the MeshUVRaycastPortal's Camera field to the Camera created by us

10. Now when you try to interact with the UI through the Quad, the UI should be responsive

See Also