So you know how you can have different sorting layers for sprites, so that you can put one in front or another behind? Well for 3D text objects there’s no such thing, and so I don’t know how to get my 3D text to appear infront of my sprite background. It always goes behind it so I can’t see it. I tried changing the Z value, to get it infront of the sprite, but that still didn’t work.
Hi, this is my problem right now. it seems that it cannot show the 3d text on the game. tried changing z value too,but didn;t work… Im still having problems with this.
If it was, the docs would say so, and the script would generate an error. I really doubt you have 100 sorting layers in your project, so try using the layers you actually have.
That is the actual answer, I just figured it out. Thanks The sortingLayerID has to be created in the inspector beforehand. No idea if there’s a way of creating them from code.
I just learned something you all haven’t thought of…
I just wasn’t satisfied by fixing the sorting via script, so I was messing around and figured that I could create a sorting layer called “Background” behind Default sorting layer ( where all 3D objects and texts are ) and put everything that I wanted to be behind 3D objects in it. And ( as you may figured ) created a “Foreground” sorting layer in front of Default so if I wanted to but some sprite in front of the 3D stuff and it worked perfectly!
Place on scene a GameObject with SpriteRenderer component on it. Look at property “Order in layer” - you can set that to bring your sprite in front of another, incrementing the value will bring your object close to camera.
Place on scene a 3DText GameObject. Look at property “Offset Z” - you can set it to bring your text close to cam.
IMPORTANT!!!
If you want the text to be on top of sprite the “Offset Z” value should be bigger than “Order in layer” but it need to be a negative value, because 3DText works in 3D space, and SpriteRenderer works in 2D space, you need to set “Offset Z” (at 3DText gameObject) with a negative value to bring it more close to camera.
EX: offsetZ = (orderLayer + 1) x -1
This works for me. I hope this make sense and my english is enough readable.
The final touch that helped me with this issue after following the above two suggestions was to add a Canvas to my text label - the Canvas then allowed ‘override sorting’ which then let me set a sorting layer for it.
It’s a defect?? with the TextMesh. They didn’t add the 2 values to the inspector. Create a Script to override it those values. You won’t see it at design time, but at runtime it works fine
Cant believe this Renderer.sortingLayerID and/or Renderer.sortingOrder is the solution for my sprite not appearing in my mesh background. Been stuck here for almost 3 day.