Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by homer_3 · Jun 05, 2013 at 02:50 AM · 3d text

3D Text appears over everything

My 3D text appears over everything in my game. If I have a wall in front of my text, I don't want it to appear. I've tried resolving this using the solution in the wiki here -> http://wiki.unity3d.com/index.php?title=3DText But this only seems to work for text created in the editor.

From what I can tell, my text object I create programmatically is identical to the 3D text object created using the editor. It has all of the same components anyway. The code I use to create the text looks like

 public static GameObject CreateTextObject(Font font, Material mat)
 {
   GameObject fontObj = new GameObject();
   TextMesh tm = fontObj.AddComponent<TextMesh>();
   MeshRenderer mRenderer = fontObj.AddComponent<MeshRenderer>();
   mRenderer.material = mat;
   tm.font = font;
   Shader zTextShader = Shader.Find("Resources/Shaders/zTextShader");
   tm.renderer.material.shader = zTextShader;
   tm.renderer.material.SetTexture("_MainTex", mat.mainTexture);
 
   return fontObj;
 }

font and mat are loaded using Resources.Load and are created as described in the wiki. zTextShader is just the shader from the wiki.

Has anyone been able to generate 3D text programmatically and have it render behind objects? If so, what did you do?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Owen-Reynolds · Jun 05, 2013 at 03:30 PM

The trick is changing the shader (the rest is boilerplate object assembling.) I'd imagine that the "zTextShader" has been modified and you either missed seeing it, or they forgot to mention it.

The original shader is named Font.shader. Inside of it, change where it says "ZTEST Always" to "ZTEST Less". Then, if you ever use the normal "over everything" 3DText, change the name (top line, in quotes. The GUI/ isn't required, but seems good to keep.)

Can get the shader by downloading Unity Default shaders (then grab the Font one, open and change it,)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by homer_3 · Jun 05, 2013 at 10:39 PM

It ended up being an issue with multiple cameras. The text was being rendered in one camera and my wall was in another.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

instantiate 3d text with different names - c# 1 Answer

Problems with 3D text 1 Answer

3D Text visible from/in x distance/place 0 Answers

Fading 3d text - only fades once 1 Answer

Making a Timer Out out of 3D Text using C#. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges