TextMesh Pro - Advanced Text Rendering for Unity - Beta now available in Asset Store

Just a quick note: When creating a new Font Asset using some TTF file, you have to make sure you use the Font Render Mode (Distance Field 16 or 32). Using any other Render Modes will create a Bitmap Font Asset and assign the TMPro/Bitmap Shader to it.

When a Font Asset is created using the Distance Field 16 or 32, the TMPro/Distance Field shader is assigned to it.

There should be no difference between using an SDF or Bitmap Font Asset in terms of changing the alpha. BTW: Are you changing the TextMeshPro.color property or are you changing the material?

I would suggest, you register to the TextMesh Pro User Forum and then in the support section, post your request for help as well as your script so I can take a look at it which would make it easier to help you out.

Ok will post in forum later(my children are currently playing havoc :/) but just to be clear here for now:)

All I’m trying to do is use iTween to fade text mesh pro items in. As i would prefer to use iTween if possible as I have set up quite a lot of stuff with it already…

Now if I use bitmap material then iTweens alpha fade works.

If i use Distance field then it doesn’t and comes up with an error:


Material doesn’t have a colour property ‘_Color’
Material doesn’t have a color property ‘_Color’
UnityEngine.Material:get_color()
iTween:ColorFrom(GameObject, Hashtable) (at Assets/iTweenEditor/iTween.cs:703)
iTween:FadeFrom(GameObject, Hashtable) (at Assets/iTweenEditor/iTween.cs:523)
c__Iterator19:MoveNext() (at Assets/iTweenEditor/iTweenEvent.cs:247)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)

You should be changing the TextMeshPro.color property and not the material property. Why?

Changing the Material property will result in Instances of the material which will result in breaking batching and thus more draw calls. Whereas changing the TextMeshPro.color property changes the vertex color which allows you to still use the same material on all text objects thus making it possible to batch them and saving on draw calls.

Using TextMesh or TextMeshPro, you should be using iTween to change the .color property not the material color.

P.S. Just in case someday you wish to change the Material properties directly, the Material Property for the color of the face of the text is “_FaceColor”. The Material Property for the Outline color is “_OutlineColor”. I haven’t played with iTween but I would presume it can also access those properties.

P.S.S. Accessing Material Properties by string name is slower than using their PropertyID. To access the material properties via the ID’s, TextMeshPro has a utility class which caches those.

Here is an example to change the face color.

 m_material.SetColor(ShaderUtilities.ID_FaceColor, new Color32(255, 255, 255, 128));

P.S.S.S. If that makes sense :smile: I am off to bed since it is 3:30 AM. Feel free to reach out if you need any additional help with this.

This is a great tool. It is really amazing how little work it takes to get such good results and to easily test out new ideas. Glad I have it in my toolbox now.

Hi again

I hope you had a good sleep but sadly I’m back again as can’t work this out:/

Your above does kinda of make sense but I simply am not understanding how to target the colour vs material using iTween.

When I was using a text mesh i was able to simply create a text mesh object and drag a script like this:


usingUnityEngine;
usingSystem.Collections;

publicclassTestTween : MonoBehaviour
{

voidStart(){
iTween.FadeFrom(gameObject ,iTween.Hash(“alpha”,0,“time”,2,“delay”,1));
}
}

And this fades it in.

I’m stuck on how to do the same with a textMeshPro object as when and do the same I get that error I posted before. Namely iTweens default handling of a textMeshPro object seems to not work?

Material doesn’t have a color property ‘_Color’
UnityEngine.Material:get_color()
iTween:ColorFrom(GameObject, Hashtable) (at Assets/Plugins/Pixelplacement/iTween/iTween.cs:707)
iTween:FadeFrom(GameObject, Hashtable) (at Assets/Plugins/Pixelplacement/iTween/iTween.cs:527)

*as part of the test i am using the impact sdf font part of text mesh pro install. And the material is set to mobile/Distance Field

I appreciate your help so far:)

ade

I have never used iTween so I don’t know if there is a way to tell it what custom properties of an object to access. However, I have looked at the iTween code that deals with color and made the following changes to enable it to change / modify the TextMeshPro.color property

You will have to make the following changes yourself.

  1. Move the iTween folder from the Plugins folder to another folder like StandardAssets. This is needed so we can add the TMPro namespace.
  2. Make the following changes iTween.cs file.
// In the Namespaces region, add the following
using TMPro;

// In the ColorFrom Function we need to add the code to check and get the color from the TextMeshPro.color property.

//set tempColor and base fromColor:
if(target.GetComponent<GUITexture>()){
            tempColor=fromColor=target.guiTexture.color;  
}else if(target.GetComponent<GUIText>()){
            tempColor=fromColor=target.guiText.material.color;
}
// Insert here...
else if(target.GetComponent<TextMeshPro>())
{ 
            tempColor=fromColor=target.GetComponent<TextMeshPro>().color;       
} // End insert
else if(target.renderer){
            tempColor=fromColor=target.renderer.material.color;
}else if(target.light){
            tempColor=fromColor=target.light.color;
}

// Still in the ColorFrom function...

//apply fromColor:
if(target.GetComponent<GUITexture>()){
            target.guiTexture.color=fromColor;   
}else if(target.GetComponent<GUIText>()){
            target.guiText.material.color=fromColor;
} // Insert here...
else if (target.GetComponent<TextMeshPro>())
{
            target.GetComponent<TextMeshPro>().color = fromColor;
} // End Insert
else if(target.renderer){
            target.renderer.material.color=fromColor;
}else if(target.light){
            target.light.color=fromColor;
}

// Lastly in the GenerateColorToTarget, we also add some new code

//from and init to values:
if(GetComponent<GUITexture>()){
            colors = new Color[1,3];
            colors[0,0] = colors[0,1] = guiTexture.color;
}else if(GetComponent<GUIText>()){
            colors = new Color[1,3];
            colors[0,0] = colors[0,1] = guiText.material.color;
} // Insert here...
else if (GetComponent<TextMeshPro>())
{
            colors = new Color[1, 3];
            colors[0, 0] = colors[0, 1] = GetComponent<TextMeshPro>().color;          
} // end insert
else if(renderer){ ...

With these changes, I was able to fade the vertex color of the TextMeshPro object using iTween. Like I said, I have never used iTween. There might be a way to have it use custom properties of custom objects. Maybe someone familiar with it can chime in.

Thanks of ridging into this Stephen. It doesn’t break now but it doesn’t seem to actually interpolate between the values. I am going to look at some other tween engines as in my googling yesterday some had issues with 2dtoolkit objects and iTween and it sounded like they same/similar problem.

Sorry for typos in last post

ridging = digging

Stephen = Stephan

:confused:

Hi

Just a brief update in regards tweening systems and text mesh pro, in case this is of use to anyone else:)

I have shifted over from iTween to LeanTween…this lets you set custom properties (so can modify text mesh colour property to fade in and out etc) so it does what I need which is great news:)

ITween may well do but I just found Lean Tween easier to run with

Glad to know that LeanTween works with custom properties and for you :slight_smile:

Took a short break from working on the support for Unity 4.6’s Auto Layout System.

This is another simple script which tweaks the position of the vertices. What is kind of cool about this, is that I can actually change the text or properties of the object like alignment, character spacing, etc and the letters keep on dangling around :slight_smile: I’ll try to make a short video showing that off tomorrow.

Made some tweaks to the example Vertex Attribute Animation script. In this example I am applying and offset to the position of each character as well as random rotation.

These changes now make it possible to change the text and property of the object at run-time while those FX are still on-going.

Here is a Side by Side of TextMesh Pro vs. UI Text in Unity 4.6.

1 Like

Just testing stuff out (well maybe a bit of playing around) :slight_smile:

This text style is using vertex gradient colors along with some Outline with a bit of dilation. You can also see the bevel and soft shadow along with the blue glow.

I am also using a small script to animate the vertex positions using an animation curve.

Here is the text before and then after tweaking the material properties.

Basically most of the properties of the text object can be changed as run-time. Here I am simply changing the curve scale.

Any idea why my fonts aren’t rendering properly at runtime?

In the editor they look fine, but at runtime, all I get are white squares. This happens with all the default SDF fonts, as well as the ones I create myself. If I use a bitmap font, it renders fine.

Text on left is using BitmapFont, other are using SDF font:

Err, they were rendering properly in the editor, but now have somehow become corrupted, rendering very thin outlines around each letter. If I change to one of the pre-supplied SDF fonts it renders ok (Still broken at runtime though)

Again, image on left is using Bitmap, other 2 are SDF:

Hi Shawn,

Can you load the example scene 01 that came with TextMesh Pro and see if the renders correctly at a build on your end. Make sure that it is still using the TMPro/Mobile/Distance Field shader.

Can you also give me some information on what version of Unity you are running and it looks like a PC right.

Please take the time to register to the TextMesh Pro User Forum which will make it easier to help you out and where you will also find solutions to potentially similar problems. If it is more convenient for you to email me, please feel free to do so at Support@DigitalNativeStudios.com.

P.S. Now that I saw your post, I’ll be standing by my email to get your update so I can help you get this sorted out.

Good news, I found the problem :smile: Setting the localScale.z = 0 caused the TMP instances to render as white squares. For bitmapFonts, this seems not to be a problem.

We had some code that was scaling the transforms of our GUI, to match the zoom of the Camera. The fix was to change this line:
guiParent.transform.localScale = new Vector2(uiScale, uiScale);
to:
guiParent.transform.localScale = new Vector3(uiScale, uiScale, 1);

Working like a champ now! Thanks for the amazing plugin, very impressive work.