Author Topic: Text along a curve  (Read 63579 times)

tayl0r

  • Beta User
  • Newbie
  • *
  • Posts: 13
Re: Text along a curve
« Reply #30 on: July 09, 2015, 03:58:30 PM »
Thanks for the update. I do want the texts to be static, I won't be changing the text once the game object it's part of is active. Is there a way to do that and would that fix the problem? I'd much prefer than than running this every frame.

EDIT: 
Quote
Although the Layout Element is set to Ignore Layout on the parent, Unity is still calling the Layout callbacks on the child text object which I am not certain why.
And yet when I add a LayoutElement set to Ignore Layout on the text, it didn't fix the problem. Did you have the same result?
« Last Edit: July 09, 2015, 04:02:48 PM by tayl0r »

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: Text along a curve
« Reply #31 on: July 09, 2015, 04:10:44 PM »
Thanks for the update. I do want the texts to be static, I won't be changing the text once the game object it's part of is active. Is there a way to do that and would that fix the problem? I'd much prefer than than running this every frame.

I am trying to figure out if this behavior is correct in Unity as it seems strange to me that child of a parent which has Ignore Layout enabled would still be getting Layout related callbacks. http://forum.unity3d.com/threads/question-about-layout-element-ignore-layout.339748/

Hopefully, I get a quick answer from Unity which will help figure out the best way to handle this.

tayl0r

  • Beta User
  • Newbie
  • *
  • Posts: 13
Re: Text along a curve
« Reply #32 on: July 14, 2015, 12:53:14 PM »
Since Unity is being slow to respond, I thought I'd try your fix by commenting out those few lines but I'm still not getting any curving on texts in a layout group. Was there something else I should do here?

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: Text along a curve
« Reply #33 on: July 14, 2015, 11:39:16 PM »
Since Unity is being slow to respond, I thought I'd try your fix by commenting out those few lines but I'm still not getting any curving on texts in a layout group. Was there something else I should do here?

The issue is that the Layout Component keeps forcing the regeneration of the text object and thus wipes out the modifications. Let me see if I can find some way around this.

P.S. Let's make sure we keep that post bumped to try to get a reply from Unity.

abstractmachine

  • Newbie
  • *
  • Posts: 13
Re: Text along a curve
« Reply #34 on: July 27, 2015, 10:47:01 AM »
I have a fairly complete solution that integrates a spline editor with TextMeshPro for arbitrarily laying out text on a curve, similar to what you might find in Illustrator or Inkscape. I've also added the possibility of revealing the text on the curve.

It's a little wonky in places, but nevertheless works pretty well. There are a few lines of code that feel a little hack-y, related to enabling/disabling TextMeshPro's layout. Thus I wasn't able to make use of the maxVisibleCharacters method for the text reveal, but there's probably just some subtlety I'm missing. Whatever the case, it might be a good starting point.

I currently have it in a private GitHub repo. Since it integrates TextMeshPro code, I can't release it publicly. That said, I'm perfectly willing to open-source the non-TMP part of the solution. Or if Stephan wants to use it as a basis for his own work I can share the repo with him and let him integrate it into TextMeshPro.

Let me know.

I've added some screenshots below.

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: Text along a curve
« Reply #35 on: July 27, 2015, 10:57:58 AM »
I have a fairly complete solution that integrates a spline editor with TextMeshPro for arbitrarily laying out text on a curve, similar to what you might find in Illustrator or Inkscape. I've also added the possibility of revealing the text on the curve.

It's a little wonky in places, but nevertheless works pretty well. There are a few lines of code that feel a little hack-y, related to enabling/disabling TextMeshPro's layout. Thus I wasn't able to make use of the maxVisibleCharacters method for the text reveal, but there's probably just some subtlety I'm missing. Whatever the case, it might be a good starting point.

I currently have it in a private GitHub repo. Since it integrates TextMeshPro code, I can't release it publicly. That said, I'm perfectly willing to open-source the non-TMP part of the solution. Or if Stephan wants to use it as a basis for his own work I can share the repo with him and let him integrate it into TextMeshPro.

Let me know.

I've added some screenshots below.

That is pretty cool and I am sure other TMP users would find this very useful.

Did you end up having to modify any of the TMP source files or is this additional scripts that simply rely on the user having TMP?

If they are additional scripts, you are welcome to post those in this thread just like I posted the VertexAttributeModifier script.

When I have time, I'll take a look as well and see if I can think of potential tweaks and ways to make it work with the maxVisibleCharacters.

abstractmachine

  • Newbie
  • *
  • Posts: 13
Re: Text along a curve
« Reply #36 on: July 29, 2015, 12:45:36 PM »
Quote
Did you end up having to modify any of the TMP source files or is this additional scripts that simply rely on the user having TMP?

No, I just used the latest TMP Beta 2 for Unity 5 code.

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: Text along a curve
« Reply #37 on: July 29, 2015, 07:13:09 PM »
Quote
Did you end up having to modify any of the TMP source files or is this additional scripts that simply rely on the user having TMP?

No, I just used the latest TMP Beta 2 for Unity 5 code.

It is up to you on how you wish to share your additional scripts. You can create a package which only contains your custom scripts / implementation or share with me via email and provide and let me know if / how you would like me to share it with other users.

I certainly would like to see your implementation to take a look at the maxVisisbleCharacters and see how we could make it work for your needs.

Evgeny

  • Beta User
  • Full Member
  • *
  • Posts: 138
Re: Text along a curve
« Reply #38 on: July 30, 2015, 03:31:36 AM »
I am trying to figure out if this behavior is correct in Unity as it seems strange to me that child of a parent which has Ignore Layout enabled would still be getting Layout related callbacks. http://forum.unity3d.com/threads/question-about-layout-element-ignore-layout.339748/

Hopefully, I get a quick answer from Unity which will help figure out the best way to handle this.
Just in case, Unity has answered :)

bsokol

  • Newbie
  • *
  • Posts: 12
Re: Text along a curve
« Reply #39 on: October 10, 2015, 11:00:46 AM »
Hi Stephan,
any chance to update VertexAttributeModifier.cs to code compatible with TextMeshPro 0.1.52 Beta 2?

digifilm

  • Newbie
  • *
  • Posts: 2
Re: Text along a curve
« Reply #40 on: October 17, 2015, 06:02:45 AM »
Please update the script. Iam getting this error too.

TextMesh Pro/Scripts/VertexAttributeModifier.cs(94,55): error CS1061: Type `TMPro.TMP_MeshInfo' does not contain a definition for `vertexColors' and no extension method `vertexColors' of type `TMPro.TMP_MeshInfo' could be found (are you missing a using directive or an assembly reference?)

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: Text along a curve
« Reply #41 on: October 17, 2015, 11:59:49 AM »
Please update the script. Iam getting this error too.

TextMesh Pro/Scripts/VertexAttributeModifier.cs(94,55): error CS1061: Type `TMPro.TMP_MeshInfo' does not contain a definition for `vertexColors' and no extension method `vertexColors' of type `TMPro.TMP_MeshInfo' could be found (are you missing a using directive or an assembly reference?)

I revised a few of the function of this script which can be found in the following post http://digitalnativestudios.com/forum/index.php?topic=712.msg5463#msg5463. I didn't revise all of it but my changes should enable you to get a better understanding of the process so you can make further modifications if needed.


RedVonix

  • Newbie
  • *
  • Posts: 2
Re: Text along a curve
« Reply #42 on: November 10, 2015, 01:45:28 PM »
I'm attempting an integration of this concept so I can write words in a circle, however I'm having an odd problems where the letters don't move at all. Just to kick off my code testing, I'm making it so it will shift all the letters with an offset on the Y coordinate. I've got my test coded up, but when used in the game - the letters never move. No errors or warnings either so I'm guessing the code is right - just my integration is wrong. Below is the code for this function... any suggestions on what I'm missing or just doing wrong?

Code: [Select]
private void setCircularTitle()
{
lockedTitle.ForceMeshUpdate(); // lockedTitle is a previously defined and acquired TextMeshPro object.

Vector3[] vertices = lockedTitle.mesh.vertices;
int charCount = lockedTitle.textInfo.characterCount;
for(int i = 0; i < charCount; i++)
{
TMP_CharacterInfo charInfo = lockedTitle.textInfo.characterInfo[i];
int vertexInfo = charInfo.vertexIndex;
Vector2 charMidBottomLine = new Vector2((vertices[vertexInfo].x + vertices[vertexInfo + 2].x) / 2, charInfo.bottomLeft.y);

Vector3 offset = new Vector3(0f, 25f, 0f);// charMidBottomLine;
vertices[vertexInfo + 0] += -offset;
vertices[vertexInfo + 1] += -offset;
vertices[vertexInfo + 2] += -offset;
vertices[vertexInfo + 3] += -offset;
}

lockedTitle.mesh.vertices = vertices;
lockedTitle.mesh.uv = lockedTitle.textInfo.meshInfo.uv0s;
lockedTitle.mesh.uv2 = lockedTitle.textInfo.meshInfo.uv2s;
lockedTitle.ForceMeshUpdate();
}
« Last Edit: November 10, 2015, 01:47:25 PM by RedVonix »

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: Text along a curve
« Reply #43 on: November 10, 2015, 01:58:59 PM »
I am still out of town with limited access but at quick glance, I believe the last .ForceMeshUpdate() is the issue.

ForceMeshUpdate() forces a regeneration of the text which does a layout of the text and renders it normally. The idea behind these modifications is to get the text and geometry to be generated first and then subsequently modify the vertex attributes.

RedVonix

  • Newbie
  • *
  • Posts: 2
Re: Text along a curve
« Reply #44 on: November 10, 2015, 03:03:21 PM »
I am still out of town with limited access but at quick glance, I believe the last .ForceMeshUpdate() is the issue.

ForceMeshUpdate() forces a regeneration of the text which does a layout of the text and renders it normally. The idea behind these modifications is to get the text and geometry to be generated first and then subsequently modify the vertex attributes.

AH! Ok - I thought it just forced a re-render to update it. Though unfortunately it did not update the vertices of the label... they're still firmly in their original places. I'm guessing there's a setting or something I'm missing that allows the vertices to be moved...?