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

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).

Related

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

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.

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.

How to add the new unity uxml(via ui builder) to game screen?

I installed the new Unity UI Builder. Everything works just fine...
But how do I add the uxml to my scene or how do I attache it to camera?
I tried to drag and drop the uxml to camera and I searched for a component, but I couldn't find anything... Is there any official documentation?
You must use an gameObject with PanelRenderer.cs attached to it:
For now, I only know you have to set UXML file and USS file. In play mode, by magic (I still don't understand how unity does it), it will render.
In the Github project you can see how things are for now. UIElementsUniteCPH2019RuntimeDemo
EDIT:
The project linked above uses UI Builder 0.8.
Runtime support is still not available using the packet manager.
You can add the preview version to your project by adding the following line to your manifest.json (it's located in the projects Packages-folder)
"com.unity.ui.runtime": "0.0.4-preview"
You may want to check whether a newer version is available.
Keep in mind that the preview version is intended for previews only. The api and workflow might change with newer versions.
Once runtime support is enabled you can use the Panel Renderer as described above.
In Unity 2021.2, when you add a UI Document to the hierarchy, a PanelSettings asset is automatically created and assigned to the that UI Document.
Simply add your uxml file to the UI Document -- there is no Panel Renderer component anymore.
Even though the UI Builder offers a preview of the menu over the actual game scene, there is no way to use that menu in a game using Unity's functionality or packages. To do that we need to use the code that comes with the demo by Damian Campeanu from Unite Copenhagen 2019 that you can find here: https://github.com/Unity-Technologies/UIElementsUniteCPH2019RuntimeDemo.
The demo has following structure.
Structure of the project
The files that we are interested in are located in Assets/UIRuntime folder. Simply copy this folder into Assets folder of your project.
After copying the the folder,create empty game object, and add two components in the inspector. Panel Scaler and Panel Renderer.
Game menu object with panel scaler and panel renderer components
Panel Scaller is responsible for scalling your menu for the display. Choose "Constant Physical Size" and 96 for both Reference and Fallback DPI. Those are the values from the original demo and 96 DPI is a typical pixel density for most computer screens (it is different on mobiles and high density screens).
Panel Renderer is the place where you will set your UXML and USS (Unity Style Sheet) files (Uxml and Unity Style Sheet fields. Leave the last two of fields empty, and tick the "Enable Live Updates" checkbox. This will enable you to show the updates in the game viewport as you make them.
I wanted to comment under existing answer by Pablo but I'm new so I can't.

How do you get the Eclipse menubar to update on demand?

I'm working on a plugin aiming to hide a swathe of menu contributions, then slowly reintroduce them to the UI according to how confident/experienced the user is, with help and introductory information given to the user at each step. So far I can happily hide menu contributions using activities. Getting them back has proved to be slightly more difficult, however.
I have menu contributions being hidden and shown via activities, but the problem I've run in to is that the menu isn't instantly updating to reflect the activites. When my provided variable is changed, the activities are being started/stopped appropriately, but the menu doesn't immediately change. That is, until you change view or perspective- actions which cause the menu to be refreshed.
I've tried calling refresh() on the MenuManager, as per this question, to no avail.
Obviously my expression is being evaluated immediately, but how can I get the menu itself to update/refresh immediately?
Thanks!
It turns out there were issues with fireSourceChanged().
Calling: fireSourceChanged(int sourcePriority, Map sourceValuesByName) doesn't work for me.
But calling fireSourceChanged(int sourcePriority, String sourceName, Object sourceValue) does work.
I really don't know why that is - could be an Eclipse bug??