How to make a Mixed Reality app for the Quest 3 - Part 3: Plane Visualization
Vložit
- čas přidán 16. 07. 2024
- This is the third part of a short tutorial series, in which you will learn how to create Mixed Reality experiences on the Meta Quest 3. We will be building our app in the Unity game engine, using Unity's native 'XR Interactive Toolkit'.
In this video, I will show you how to create your own custom 'Plane Visualization'. I'll also show you how to set up a Touch Controller button, so that you can toggle the Plane Visualization on and off.
→ Next Video • How to make a Mixed Reality app for the Quest 3 - Part 4: Using Planes: • How to make a Mixed Re...
← Previous Video • How to make a Mixed Reality app for the Quest 3 - Part 2: Plane Detection: • How to make a Mixed Re...
📜 Get the Source Code for this tutorial: / source-code-how-99774461
► Tutorial Series Playlist: • How to make a Mixed Re...
▬ Support My Work ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
❤️ Support me on Patreon: / ludicworlds
☕ Buy me a coffee: ko-fi.com/ludicworlds
The 'Unity Asset Store' links provided below are affiliate links. If you click on them and make a purchase, I may receive a small commission at no extra cost to you. This support helps me continue creating content for this channel.
🏷️ Spring Sale: assetstore.unity.com/?aid=110...
⚡ Flash Deals: assetstore.unity.com/?flashde...
🏷️ 50% Off: assetstore.unity.com/?on_sale...
Thank you for your support!
▬ Timestamps ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
0:00 - Intro
1:22 - Debug Panel
3:03 - Custom Plane Prefab
9:06 - Touch Controller Input
11:05 - Toggle Planes Script
17:56 - Testing App
18:22 - Outro
▬ Useful Links ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
► github.com/LudicWorlds/unity-...
► Unity OpenXR: Meta docs: docs.unity3d.com/Packages/com...
► AR Foundation docs: docs.unity3d.com/Packages/com...
▬ Credits ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
► Music by - CO.AG Music: / @co.agmusic
#Unity #Quest3 #mixedreality #VR - Věda a technologie
I keep coming back to your channel to see when part 4 will be out. Looking forward to it. Don't keep us waiting too long.
I love this series, thank you!!
Best videos on Mixed_Reality Application Developing on CZcams. Super clear, perfect speed, exhaustive explanation. Thank you and keep up the good work! I am thrilled to learn more :)
Thanks for the kind words! Working on the next MR tutorial right now. :)
Great tutorial. Thank you.
THE BEST TUTORIAL FOR MR SO FAR
This tutorial is very useful.Thank you
Thank you, well explained !
Very well made video!
With Oculus Quest it is possible to achieve exact plane detection, automatically obtaining the angles of the physical object?
I've checked Udemy but I couldn't find a course explaining all this like the way you do it, your format is great. Would also like to read additional documentation on all the options you're showing us. Instant buy for me if you would create a full course on this.
Thanks for the encouragement! I'm actually seriously considering creating a Udemy course (which would certainly go into more detail than I do here).
Well explained as usual. Maybe Spatial Anchor could be next ?
Thanks! :) I'm currently making a short tutorial about physics interactions. But the next one will be 'Spatial Anchors' for sure!
All this is great, but the big question is if there's a way to develop an MR app for both the Quest and Vision Pro. If you want to develop for both platforms, what's the best approach?
Great videos, im using this info on my current app. I do have one question. You know when you put the headset on and a message comes up and says it has noticed new obstacles in your area? And it shows the red lines of the new objects, is that data available to use as well?
Unfortunately, I don't think that this 'obstacle detection' data is accessible (through the 'Unity OpenXR Meta' package or the 'Meta SDK'). At least, I'm not aware of any way to get this data.
Thanks for the reply. I appreciate your time.
is there any mask plane component that can mask virtual geometry behind it (or perhaps a stencil component)? eg. lets put a virtual door in a real room - wearing a quest3, we see thru the door into another room - a virtual 3d environment - but to the left or right of the door we see our room.. and when we enter the door - we enter a virtual space wider than the door.. looking back we see the door is now a portal back into the real room
so how to mask the virtual room so only the door is seen when standing in the real room?
Maybe this tutorial can help? (AR Portal Setup With URP) czcams.com/video/Y1lzXWD8NN8/video.html
Thanks for your tutorials, are very useful and clear, excuse me, I am overload 3d models using MRUK, I am having a little issues, the 3D models are moving to the left and the front (compared to the phyisical space (Passthrough)), they move very slow but it will make the app does not work well, do you had similar isssue? thanks in advance.
Are these animated characters? With static 3d models I've not noticed drifting while the app is running.
@@LudicWorlds No, actually they are static, but thanks for your feedback. I will keep trying.
How can I make it so that the planes are off when i first run the game? Instead of having them on and having to push a button to turn them off?
Thanks for the great work! I have a question. I tried to follow along line by line from your script, but after I save and close, I don't see any "Toggle Planes Action" field. Maybe I have done something wrong in the script?
This is everything I have:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.XR.ARFoundation;
[RequireComponent(typeof(ARPlaneManager))]
public class SceneController : MonoBehaviour
{
[SerializeField]
private InputActionReference _togglePlanesAction;
private ARPlaneManager _planeManager;
private bool _isVisible = true;
private int _numPlanesAddedOccured = 0;
// Start is called before the first frame update
void Start()
{
Debug.Log("-> SceneController::Start()")
_planeManager = GetComponent();
if (_planeManager is null)
{
Debug.LogError("-> Cannot find 'ARPlaneManager' :( ");
}
_togglePlanesAction.action.performed += OnTogglePlanesAction;
_planeManager.planesChanged += OnPlanesChanged;
}
// Update is called once per frame
void Update()
{
}
private void OnTogglePlanesAction(InputAction.CallbackContext obj)
{
_isVisible = !_isVisible;
float fillAlpha = _isVisible ? 0.3f : 0f;
float lineAlpha = _isVisible ? 1.0f : 0f;
Debug.Log("-> OnTogglePlanesAction() - trackables.count: " + _planeManager.trackables.count);
foreach (var plane in _planeManager.trackables)
{
SetPlaneAlpha(plane, fillAlpha, lineAlpha)
}
}
private void SetPlaneAlpha(ARPlane plane, float fillAlpha, float lineAlpha)
{
var meshRenderer = plane.GetComponentInChildren();
var lineRenderer = plane.GetComponentInChildren();
if (meshRenderer != null)
{
Color color = meshRenderer.material.color;
color.a = fillAlpha;
meshRenderer.material.color = color;
}
if (lineRenderer != null)
{
// Get the current start and end colors
Color startColor = lineRenderer.startColor;
Color endColor = lineRenderer.endColor;
// Set the alpha component
startColor.a = lineAlpha;
endColor.a = endColor;
//Apply the new colors with updated alpha
lineRenderer.startColor = startColor;
lineRenderer.endColor = endColor;
}
}
private void OnPlanesChanged(ARPlanesChangedEventArgs args)
{
if (args.added.count >0)
{
_numPlanesAddedOccured++;
foreach (var plane in _planeManager.trackables)
{
PrintPlaneLabel(plane);
}
Debug.Log("-> Number of planes: " + _planeManager.trackables.count)
Debug.Log("-> Num planes added Occurred: " + _numPlanesAddedOccured)
}
}
private void PrintPlaneLabel(ARPlane plane)
{
string label = plane.classification.ToString();
string log = $"Plane ID: {plane.trackableId}, Label:{label}";
Debug.Log(log);
}
void OnDestroy()
{
Debug.Log("-> SceneController::OnDestroy()");
_togglePlanesAction.action.performed -= OnTogglePlanesAction;
_planeManager.planesChanged -= OnPlanesChanged;
}
}
Thankyou! Did you precede the '_togglePlanesAction' variable with the [SerializeField] attribute? Like this:
[SerializeField]
private InputActionReference _togglePlanesAction;
Alternatively, you can also make the variable 'public' (as this should also expose the variable in Unity's Inspector)
public InputActionReference _togglePlanesAction;
Also, ensure that Unity is not in 'Play Mode' while editing scripts (or components in general). Hope this helps!
Thank you for the great tutorial. I have a question. I followed along line by line from your script, but after I save and close, I don't see any "Toggle Planes Action" field. Instead I get this error message from unity: "error CS0246: The type or namespace name 'InputActionReference' could not be found (are you missing a using directive or an assembly reference?)". I also tried making the variable public but that did'n work as well. Would you happen to know what did I do wrong?
Check the 'using' statements at the top of file. Make sure they include the following using directive:
using UnityEngine.InputSystem;
Same problem here. Checked my using statements, no problem there. I restarted the project, had to open it in safe mode, closed it again, opened it again and my scene was completly empty. It only made it worse, bc now most of the work is gone
One question, after creating the Scene Controller Script I dont have the Toggle Planes Action inside the Inspector. Would you happen to know what did I do wrong?
nvm, got it
Having the same issue here. Could you please explain what went wrong, and how you solved the problem?
@@JoseAfsharipour The problem is inside the script, once you have 100% what he has, it will work!
When I double click the Scene controller script it doesn’t open like yours. It asks me to select an app to open the file and gives me options such as notepad, word or windows media player. Do I have to add something to my project to get it to open in the project like yours?
Did you opt to install Visual Studio when you first installed Unity? If not, go back into 'Unity Hub', go to the 'Installs' section, click the 'cog' icon next to the Unity version that you are using, and select 'Add modules'. From there you can install 'Microsoft Visual Studio Community' Edition.
If Visual Studio IS installed: In the Unity Editor, go to the top menu-bar and select: 'Edit' -> 'Preferences'. In the 'Preferences' window select 'External Tools'. Make sure that 'External Script Editor' is set to 'Visual Studio'.
Thank you so much I didn’t have it installed. I got it now. I don’t know anything about coding literally learning from scratch. I added the second line the “[serializefield] and “inputactionreference “ isn’t turning green. Does it need to?
@@samanthaah263 Its important to type variable Types exactly as shown in the example. For instance, make sure you type "InputActionReference" not just “inputactionreference“. Whether it turns green specifically, will depends on the color scheme you have set in Visual Studio (which could be different from mine).
👍