How to change scene based on button click using Unity and MRTK? - unity3d

I'm trying to implement a menu with some buttons in order to load different scenes based on the clicked button.
What I've tried
I created a total of 3 scenes : menu, main and secondary. The menu scene contains the buttons. On the first button I added Interactable, NearInteractionTouchable and LoadContentScene. I then selected the desired scene to load in LoadContentScene and added an OnClick event to the Interactable script which triggers LoadContentScene.LoadContent.
you can see it there
The problem
Now when I click on my button, the next scene isn't loading and I have those error messages in my Unity console :
Unable to find ISceneTransitionService service.
NullReferenceException: Object reference not set to an instance of an object
Microsoft.MixedReality.Toolkit.Extensions.SceneTransitions.LoadContentScene.LoadContent () ...
What did I do wrong ? I tried to find some solutions in the documentation or online but I couldn't find any tutorials

From the error message you are trying to use the Scene transition service, please check if this service is registered in MixedRealityToolkit->Extensions. To clarify, for scene loading, this service is not necessary, if you don't know what it does, you can disable the corresponding code.
Also, you can refer Scene system content loading - MRTK 2 | Microsoft Learn and this official sample - OpenXR-Unity-MixedReality-Samples/BasicSample at main · microsoft/OpenXR-Unity-MixedReality-Samples · GitHub.

Related

Hololens 2/Unity Error: A material (Instance)(Instance)... which is already instanced was instanced multiple times

I have instanced a simple scrolling menu prefab in my scene (prefab provided by MRTK2 with just one menu option available). I have a button in the scene that when clicked will either SetActive(true) or SetActive(false) on this menu to show/hide it. When the menu is SetActive(false) and then SetActive(true) it provides the sequence of errors depicted in the picture below. I've found this thread that may be related but ultimately I don't know what this error means or how to fix it.
It seems that all of these errors are w.r.t. components on objects in the menu that existed from the prefab, so I'm confused as to why these errors are happening. I tried to replace the components with their MRTK counterparts as I was reading somewhere that MRTK versions of shaders, etc. are more efficient and was hoping that maybe they would simply solve the issue (they haven't).
For example, it seems that the error regarding MRTK_PressableInteractablesButtonBox (Instance) (Instance) is the shader on the FrontPlate of the button in the menu option.
Similarly, the error regarding sequisb SDF Material (Instance) (Instance) is the FontAsset on the TextMeshPro under the menu option's IconAndText object.
Unfortunately, my solution doesn't provide an explanation as to what caused my original error. However, I was able to get everything working by simply scrapping the old menu and recreating from the same prefab. I guess cross-wiring must have occurred at some point that I was unable to trace down. Ultimately, all I needed was a scrollable menu with a click event listener and buttons with custom meshes...all of which seem to be working fine now.
Thanks to #Zuocheng Wang and #derHugo for pointing me in the right direction (i.e. that things "should" work essentially out-of-box for the desired functionality).

Why is my button isn't working - Unity 3D

i'm making a game on unity and i don't know why but my button "Upgrade" doesn't work, i can't click it, i searched for solutions and here is what i tried :
check if any UI is blocking the way
check if i had "interactable" and "raycast target" activated
check if i had an event system
maybe it is from the physics settings in Edit -> project settings -> physics
because i had to deactivate some things for other stuff, but i think i already tried to reactivate all to see what it did.
https://i.stack.imgur.com/eGhEw.png
here is the project in version 2020.3.33f1 if you want to try something :
https://www.mediafire.com/file/6o17nul40eqtlu9/Mini_RPG.zip/file
I do believe that EventSystem should be outside of Canvas.
It also may be the fact that the button does not have an OnClick event property set, unless you are setting it through code.
I figured it out, you can't put a button on a image (set it as his child), i replaced the image by a pannel and it works.

No function dropdown in AnimationEvent in Unity

I try to handle some events during animations, but everywhere I look, every tutorial have access to AnimatorEvent Inspector like this:
A nice simple field, where you can select a function, I want this!
But instead of this, I always getting this sick 5 fields view, and don't have any idea how to handle animation event in this case!
I tried to create function test() with debug log, but it didn't work anyway. Why I can't get access to this simple window where I can choose an function?
You will need to add this animation into a State in Animator Controller (via Animator Window).
In the object which contains Animator component, attach your script component to it.
Open the Animation window, select the object above, you will see a dropdown of animations (top left) which Animator Controller of this object contains. Choose and add event to the animation you want to.
Select the event in Animation Window, in the Inspector, you should see the dropdown of public functions of your script component attached above.
Answer by Aluminium18
Sometimes it doesn't work even if you do all things according to tutorials or advices in internet. I often leave Unity editor launched for a long time without any interactions with it. After several gibernations and several days it can get buggy - various errors appear, you can't see some functions from scripts and so on. So, just reloading the Unity editor solves many of such issues for me. And it continues to happen so for several years no matter what Unity version you have. I tried versions from 2019.x.x to 2022.x.x - all this time Unity behaves itself the same.

Are there any developers using Unity OVRInput class to access the Oculus secondary controller?

I am trying to use the right(secondary) controller in two unity projects. OVRInput auto-populates the button and axis-n object names in MSVS2017 from the OVR classes but the return values from the right(secondary) controller always show false. The Unity XRInputManager demo shows the results from both controller inputs and headset data. But this does not use OVRInput. Would like to use OVRInput but might not be able to. The Quest is fairly new so all the Internet doco shows nothing but Go specifications. Go has one controller. I can read all buttons from the left hand(primary) controller. MY apk responds correctly on my GO with the only controller.
OVRInput.GetButton(OVRInput.RawButton.A,Rtouch) ;// reports false in the event of 'A' button press.
As stated I am using OVRInput and it does not report the secondary controller inputs although Unity input mapping Input manager demo does. Input manager does not use OVR utilities.
if (OVRInput.Get(OVRInput.Axis1D.SecondaryHandTrigger, OVRInput.Controller.RTouch) == 1) // reports false in the event of grip button press.
Neither device or software reports hardware change. Should be true or false. As a side note: None of the inputs show any value change from the right(secondary) Oculus Quest controller. I have reported this to Oculus too.
As far as I know the Oculus-Quest uses Oculus-Touch controllers.
The button mapping for all controllers can be found here.
It should be e.g.
OVRInput.Get(OVRInput.RawButton.A, Controller.RTouch)
or also see the example:
// public variable that can be set to LTouch or RTouch in the Unity Inspector
public Controller controller;
// returns a float of the Hand Trigger’s current state on the Oculus Touch controller
// specified by the controller variable.
OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, controller);
// returns true if the primary button (“A” or “X”) is pressed on the Oculus Touch controller
// specified by the controller variable.
OVRInput.Get(OVRInput.Button.One, controller);

Firebase : Read-only & non-realtime mode activated, How to add child node on console

Right now, my Firebase only has read mode activated as seen by the warning message below:
I need to add a child node to somewhere with a lot of child nodes or just edit the information to create a new feature. However I don't want to do it programmatically as I have to change a lot of things in how I read the data, is there a way to add a child node for somewhere with a lot of child nodes using the console?
This article has the key.
Basically, just change the URL up top (near the "Go" button) to point to the node you want to add. After you press Go, you'll have a node waiting for you to be edited.