Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Curved text with fonts facing in and out.

A topic by 99bits created Jul 29, 2022 Views: 148 Replies: 1
Viewing posts 1 to 2

Hi, very cool asset.

Does it support various types of curved text with fonts facing in and out of the curve?  For example like the image below

https://assetstorev1-prd-cdn.unity3d.com/package-screenshot/346655d0-3c55-4f5d-8...

Developer

Thank you!


If you're the same person that emailed me, forgive me for replying twice:


Yes, it does! But you have to do a bit of work based on the type of curve you're doing. There's an example scene that has a simple curve script, and here's a script I wrote that when attached to an STM object, changes the Y position of letters based on the letters X position using an animation curve:


using UnityEngine;
using System.Collections;
[RequireComponent(typeof(SuperTextMesh))]
public class BookVertexMod : MonoBehaviour 
{     [SerializeField] private SuperTextMesh stm;     [SerializeField] private AnimationCurve curve;     [SerializeField] private float effectStrength = 1f; //how much pull the curve will have     [SerializeField] private float effectWidth = 2f; //how far the curve will be evaluated. (curve can be set to not loop!)     public void Reset()     {         //get stm component         stm = GetComponent<SuperTextMesh>();     }     void OnEnable()     {         stm.OnVertexMod += Curve;     }     void OnDisable()     {         stm.OnVertexMod -= Curve;     }     public void Curve(Vector3[] verts, Vector3[] middles, Vector3[] positions)     {         for(int i=0, iL=verts.Length; i<iL; i++)         {             //verts[i].x             //change y position of vertex based on X position of vertex             verts[i].y += curve.Evaluate(verts[i].x * effectWidth) * effectStrength;             //verts[i].z         }     } }

Here's a modified version of STMVertexMod.cs I wrote that includes a script to bend single-line text along a curve: https://pastebin.com/AebgEnNm

I put that code together in about an hour, so it's missing a few features, but the point is yes, this type of manipulation is possible! But to make it work *perfect* might take a bit more modification to the script I sent.