• 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
0
Question by Frix · Nov 30, 2012 at 07:08 PM · materialinspector3dtext

Changing the colour of a 3DText through script gives a weird error

SCREENSHOTS GOT MESSED UP, CANT EMBED AND THEY'RE IN THE WRONG ORDER.

I want to change the colour of 3D text through a script, and the first time you use it, it works perfectly fine. No problem there. But the first time the text pops up, the 'Element 0' changes to 'Type mismatch', and then when you stop the game, it turns into screenshot 2.

Then the next time you start the game, the text will turn into screenshot 1.

Then you have to keep on reassigning the font material in the inspector every single time you want to start the game again. I am using a custom font, and this is my code for changing the colour: goldMesh.renderer.material.color = Color.yellow; which works perfectly fine before it spazzes out.

(edit: okay, the screenshots wont appear correctly for some reason, so just click on attachments)

wwq.png (8.0 kB)
wwe.png (613 B)
Comment
Add comment · Show 3
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 GerryM · Nov 30, 2012 at 09:54 PM 0
Share

Did you select the font in the "Text Mesh" component (last entry)? When you select a proper font you should not have to bother with the material settings in the "Mesh Renderer".

Does changing the color work when you change the font import settings?

What version are you using? 4.0? Pro?

Sometimes a simple restart of the editor (especially on windows) does help with some weird errors.

I can change the font color with your code line fine, several times, no issues here. (Unity 4.0.0f7 Pro)

avatar image Frix · Nov 30, 2012 at 10:03 PM 0
Share

Yeah, when I put the font onto it, I didn't need to change anything else. It worked perfectly. It's just the script that's messing it up, it seems to remove it from the component or something.

I don't know what you mean about the import settings. What could I change?

I'm using 4.0.0f7 Normal version.

I restarted. Still being weird.

I also totally forgot to mention that it comes with this error whilst the text popups weirdly: 'Shader wants normals, but the mesh doesn't have them'

avatar image GerryM · Dec 01, 2012 at 07:10 PM 0
Share

When you select the font in your project you can change the input settings, like "Font Color". If changing it there works, it's probably not a font issue.

Perhaps you can post the script, the one line you did post works fine.

Also, you can try everything in a new project, add a font, add a 3DText, finally add your script. Might help narrowing down the error.

Check here for the same error.

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

12 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

Related Questions

Adding a Color Change Script to a Model 1 Answer

Material doesn't have a color property '_Color' 4 Answers

Change opacity of instantiated object at collision 0 Answers

Script with variable number of variables ? 1 Answer

Material inspector, missing properties bug 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges