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

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: Text along a curve
« Reply #15 on: February 23, 2015, 03:34:33 AM »
Just for your information, it could be really great if the curve apply along the canvas and not on character ( to have the same curve with any text lenght for example )

The code example I provided could be modified to applied the curve based on different parameters like width of the canvas, width of the longest line, etc... This script is just an example of how the vertex attributes can be modified to achieve those types of results.

hadesfury

  • Beta User
  • Full Member
  • *
  • Posts: 133
Re: Text along a curve
« Reply #16 on: February 23, 2015, 04:51:39 AM »
Great thank you for your quick answer :D

doktor3d

  • Beta User
  • Jr. Member
  • *
  • Posts: 54
Re: Text along a curve
« Reply #17 on: March 11, 2015, 10:55:32 AM »
Am having problems with the WarpUI option with UGUI TMP objects. Only the first letter is modified, and the rest remain as they were. I am using the latest 4.6 beta 4 release. Did something get broken along the way maybe?
« Last Edit: March 11, 2015, 11:16:55 AM by doktor3d »

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: Text along a curve
« Reply #18 on: March 11, 2015, 12:09:39 PM »
Am having problems with the WarpUI option with UGUI TMP objects. Only the first letter is modified, and the rest remain as they were. I am using the latest 4.6 beta 4 release. Did something get broken along the way maybe?

I tried all the demo scripts using this before release the betas so it should work but I'll double check today.

doktor3d

  • Beta User
  • Jr. Member
  • *
  • Posts: 54
Re: Text along a curve
« Reply #19 on: March 12, 2015, 05:39:48 AM »
Thanks Stephan, looking forward to your findings!

wagenheimer

  • Beta User
  • Jr. Member
  • *
  • Posts: 87
    • My Personal Website
Re: Text along a curve
« Reply #20 on: March 12, 2015, 10:32:25 AM »
Is this already working on the Unity 5 version? I could not find the example.

doktor3d

  • Beta User
  • Jr. Member
  • *
  • Posts: 54
Re: Text along a curve
« Reply #21 on: March 15, 2015, 01:24:28 AM »
Hi Stephan did you manage to test this yet?

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: Text along a curve
« Reply #22 on: March 15, 2015, 01:29:51 AM »
Hi Stephan did you manage to test this yet?

As far as I know these example scripts work in Unity 5.0. I was using those at GDC last week.

EDIT I just checked again and this works fine on my end. I have attached the script I am using right now just in case, I revised it at some point.
« Last Edit: March 15, 2015, 01:41:20 AM by Stephan B. »

gecko64

  • Newbie
  • *
  • Posts: 4
Re: Text along a curve
« Reply #23 on: June 09, 2015, 07:16:54 AM »
i'm trying to put some text on a curve -- a simple arch. I got the VertexAttributeModifier but "Warp" curves the text away from the camera (bowed). How do I make it curve the text on the Y axis?

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: Text along a curve
« Reply #24 on: June 09, 2015, 12:27:41 PM »
i'm trying to put some text on a curve -- a simple arch. I got the VertexAttributeModifier but "Warp" curves the text away from the camera (bowed). How do I make it curve the text on the Y axis?

Replace the following line of code which is 421 I believe

Code: C#
  1. matrix = Matrix4x4.TRS(new Vector3(0, y0, 0), Quaternion.Euler(0, 0, angle), Vector3.one);

gecko64

  • Newbie
  • *
  • Posts: 4
Re: Text along a curve
« Reply #25 on: June 10, 2015, 08:23:18 AM »
That did it -- thanks much!

tayl0r

  • Beta User
  • Newbie
  • *
  • Posts: 13
Re: Text along a curve
« Reply #26 on: July 08, 2015, 02:53:01 PM »
Hey, thanks for this script! I have modified the WarpUI and it's working great on some TMPro's in my game. However, I want to curve some texts that are part of a layout group and it doesn't seem to work. The text in question is a child of a child of an object using LayoutElement to ignore the layout of the main UI window it's part of, but won't warp unless I remove the ContentSizeFitter and the LayoutGroup from the main UI window. Any advice? Is this expected?

Thanks!

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: Text along a curve
« Reply #27 on: July 08, 2015, 03:01:30 PM »
Hey, thanks for this script! I have modified the WarpUI and it's working great on some TMPro's in my game. However, I want to curve some texts that are part of a layout group and it doesn't seem to work. The text in question is a child of a child of an object using LayoutElement to ignore the layout of the main UI window it's part of, but won't warp unless I remove the ContentSizeFitter and the LayoutGroup from the main UI window. Any advice? Is this expected?

Thanks!

What is likely happening is the Layout component(s) are forcing a re-generation of the text object which basically resets it to a normal layout.

Basically, a way is needed to have the text object ignore the Layout Components on the parents.

Does the text affect the ContentSizeFitter? Ie. Are any of the parent adjusting size because of the text?

tayl0r

  • Beta User
  • Newbie
  • *
  • Posts: 13
Re: Text along a curve
« Reply #28 on: July 08, 2015, 03:23:49 PM »
No, parents are not adjusting based on the text.

Here's the hierarchy if that helps explain anything:
http://screencast.com/t/Pe1FBQJaxJ (can't get image to displaying in post for some reason, sorry!)

First arrow is the parent UI window. It has a ContentSizeFitter and a VerticalLayoutGroup.
Second arrow is the parent of the parent of the text. It has a LayoutElement component with "ignore layout" checked.
Last arrow is the text itself. It has just the text and the warping script attached. The parent of the text does not have any layout element scripts.

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: Text along a curve
« Reply #29 on: July 08, 2015, 03:27:24 PM »
No, parents are not adjusting based on the text.

Here's the hierarchy if that helps explain anything:
http://screencast.com/t/Pe1FBQJaxJ (can't get image to displaying in post for some reason, sorry!)
Forum seems to only be happy with jpeg images.

Quote
First arrow is the parent UI window. It has a ContentSizeFitter and a VerticalLayoutGroup.
Second arrow is the parent of the parent of the text. It has a LayoutElement component with "ignore layout" checked.
Last arrow is the text itself. It has just the text and the warping script attached. The parent of the text does not have any layout element scripts.

Let me experiment with this and see what I find.

Update: Still looking into this while also updating the VertexAttributeModifier script.

I believe the issue you are running into is a result of the following line which I added to make sure the text didn't get re-warped unless the properties of the text or the curve changed.

Code: C#
  1. if (!textComponent.hasChanged && old_CurveScale == CurveScale && old_curve.keys[1].value == VertexCurve.keys[1].value)
  2. {
  3.     yield return null;
  4.     continue;
  5. }
  6.  

So when you enter play mode, the text is curved. Then the layout Component forces the text to be re-generated but then since the properties of the text haven't changed nor the curve data, this conditional keeps happening.

Commenting out the yield return null; and continue; will resulting in the text getting warped. However, this will keep happening each frame which isn't optimum.

Do you want to the text to be warped just once (ie. it remains static)?

EDIT: 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.

« Last Edit: July 09, 2015, 03:51:55 PM by Stephan B. »