0

I have a slider scrollrect object which I populate at run time with a bunch of space ship equipment and weapons which are prefabs. The prefabs have text objects (e.g. descriptions of the equipment) as well as mesh objects. The problem I'm having is that when the player scrolls through the prefabs and they slide outside the scrollrect perimeter the text is hidden (as it should be), but the meshes are NOT hidden!

Here's the scene setup: https://i.stack.imgur.com/sR97f.png

Any ideas what I'm doing wrong?

pandron
  • 43
  • 1
  • 8
  • 1
    Those meshes are sprites, ui elements or literally meshes? Unity implements two different masks. Sprites and UI. If you are using the UI mask, I believe it will only work with UI elements such as Images. Documentation for sprite masks: https://docs.unity3d.com/Manual/class-SpriteMask.html and documentation for masks: https://docs.unity3d.com/Manual/script-Mask.html – Vitor Figueredo Oct 27 '19 at 14:33
  • They are meshes (just scaled down versions of what is used during game play). If what you are saying is true then the documentation is just a little misleading because the example Image looks like a scene of meshes. But yes, the documentation does call it an "Image", so I guess that must be the issue. I guess I'll have to use Images instead. Thanks so much for help! – pandron Oct 27 '19 at 23:30

1 Answers1

1

You can use a RenderTexture with a RawImage component and camera pointed on each inventory item. See https://answers.unity.com/questions/844742/render-texture-in-ui.html

Otherwise prerender your items to thumbnail images.

DoctorPangloss
  • 2,994
  • 1
  • 18
  • 22