microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

Scroll Object Collection instantiated Prefabs with instanced materials #8213

Closed ChrisGoettfert closed 3 years ago

ChrisGoettfert commented 4 years ago

Overview

When instantiating my own Prefab in the Scroll Object Collection it instantiates it with an Instantiated Material. That Material is not working for me, because its simply not showing anything. When draging the Material again on top of the GameObject it shows ups again.

Also interesting: It has something to do with the "ScrollingObjectCollectoin" Script, because every object that is a child of an Object with that script has the issue with the instantiated material.

Expected behavior

Instantiate with normal Materials like normal Unity Instantiate()

Actual behavior

Instantiate() with instanced materials

Steps to reproduce

Create a new scene add the DynamcList + LazyLoading Prefab to the scene Drag a Prefab into the Dynamic Item Slot of the Scrollable List Populator Script Start

Unity editor version

2019.4.5f1

Mixed Reality Toolkit release version

2.4

image

vaoliva commented 4 years ago

Hi @ChrisGoettfert. The scrolling object collection uses a ClippingPrimitive component in order to mask objects that are visible or partially visible when scrolled out of view. As the amount of renderers can increase substantially, the component adds a MaterialInstance to manage the life time of material instances accessed / created during code. This component will create a copy (instance) of the material you are using to make things lest prone to memory leak when accessing the object material in the editor. Any renderer that appears in the hierarchy of the scroll will have this material instance component added.

I wasn't able to reproduce your issue of object / mesh not rendering using different shaders like the built in mobile unlit shader. Could you provide more information on the material shader you are using?

ChrisGoettfert commented 4 years ago

Hi @vaoliva , Unfortunately I was on Vacation the last 2 weeks, sorry for the late response. Thanks for explaining the principle behind it, I think I understand that quite well.

image

I just copied the Prefab "DynamicList + LazyLoading" out of the MRTK scene. As visible in the Image, I used the MixedRealityToolkit/Standard Shader. I changed the Shader of the Button to Unlit/Color and that seems to work for now. Any idea why the other Shader didnt work?

ChrisGoettfert commented 4 years ago

image

Just as I thought that fixed my Issue, I saw another one. Like I said I just imported some prefabs like this Button Prefab. And all those prefabs use the shader MixedRealityToolit/Standard or MixedRealityToolkit/TextMeshPro for Text. But this doesnt show up when using that Material Instance. I could change all the shaders - but after all I think thats still a bug isnt it? Can you recommend a Shader I should change to (for text, icons or just color) when working with the HoloLens2? I thought MRTK Shaders are decent?

Best, Christopher

ChrisGoettfert commented 4 years ago

Another Update: So I played around with some other shaders which just work perfectly fine. I have the weired feeling that the collection wont work when using the MixedRealityToolkit Shaders?

vaoliva commented 4 years ago

When you are using the MRTK shaders, can you confirm the object that should be visible is inside the viewable area (Clipping Bounds object cube boundaries)?

Without having the project or a copy of the prefab you are trying to load is tricky to spot the issue here, but it seems to me that your objects are out of the viewable area boundaries. The scroll hide objects by inactivating them if they are completely away from viewable cube. But if content objects are partially or completely inside the clipping cube them the mask effect is applied, and any pixel outside the cube is not rendered. This mask effect only works if using MRTK shader, cause they have the properties being updated by the clipping primitive. If your object uses a non MRTK shader they will be completely visible if they are on a visible tier cell, and the object will still be disabled when their cell is not on viewable area, but they wont be correctly masked.

ChrisGoettfert commented 4 years ago

Hi @vaoliva,

I just wrote a big text about that they are in the renderers array but are not shown correctly. I now changed the Clipping Side from Outside to Inside and everything is renderer perfectly fine. Do you mind explaining me or giving me a link to a reference what the issue was here? Is my Plate rotated to the wrong side?

Thank you for your help and the development of MRTK!

Edit: Okay, I Just checked: the buttons were not inside the Clipping Bounds. I Changed the Clipping Side to Inside and it works or i rescale the clipping Bounds, I'll play around with that for a bit

david-c-kline commented 3 years ago

@MaxWang-MS, can you try this on 2.7.2 and see if it has been fixed?

MaxWang-MS commented 3 years ago

After reading through the thread it seems the issue has been resolved. Please reopen if the issue still persists.

bb1121 commented 1 year ago

I am using multiple scroll lists with radial buttons the list are disabled and active depending on which is selected but I am having issues. When the program starts the list is disabled like it should be then when it is selected everything works with no issue but if i disable the list then set it active again the redial buttons disappear but the text for them is still there and the button still functions I cannot figure out this issue any help would be appreciated.