Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

KaiClavier

475
Posts
10
Topics
506
Followers
56
Following
A member registered Jul 23, 2014 · View creator page →

Creator of

Recent community posts

Hey, that works!


I did just remember that in the VertexMod scene, I think there's a sample script that can snap the verts of a text mesh itself so specific coordinates, so that would work, too! But yeah, the centre-align doesn't like to work naturally... I really like this fix you did and if it works for you use it for sure! (That's why i ship STM with source code exposed, after all) but yeah, I'm not sure about including it for everyone... it's been a while since I've modified the pixel snapping code, so I could be forgetting about some edge case I need to watch out for.

The pixel snap option should be the same code used by Unity UI, so it's moreso meant for non-pixel fonts or canvases rendering at the same resolution. If you're getting good results without it, then you don't need it! I will have a look at that soon though, but it does just use a standard application of Unity's internal pixel snap code...


Just make sure the "quality" is your pixel font's point size, the "size" is "quality / pixel scaling" (eg. 16 pixel font / 100 pixels in a unit = 0.16 size) and that the text is aligned to your grid. (eg 100 pixels in a unit = position should be a multiple of 0.01) and everything should be fine.

Are you using HDRP/URP with your project? STM's dropshadow and outline shaders still aren't natively supported in-editor (due to URP/HDRP not supporting multi-pass shaders...), so this script can be used instead: https://pastebin.com/wWv49mgG

Ah shoot I suppose I forgot to update that part of the docs, sorry!

I combined all of STM's regular shaders with the SDF shaders, just check "SDF Mode" in the material settings to use that! So the shader you want is "Unlit Outline", and then enable SDF mode on the material.

Still no updates on the outline shader with URP besides this script: https://pastebin.com/wWv49mgG I'm really sorry about that, developing it has been a total roadblock for me no matter what direction I've tried to approach it from. I'll do some more brainstorming, because I would really like this to work finally.

Hmm... I'll try to think of how to do this, but for now you could manually edit the lists within SuperTextMesh.cs that contain the lists of characters that will attempt to not be put at the start and end of the line. Also, I believe that if you check "break text", text should ignore formatting rules if there are no spaces available to break at... I think.

Ahh, I see... I hope after this change we made it's working as expected? (I still haven't published it yet, sorry...) If you see any more errors or things that should be working differently, please let me know! I'm still embarrassed I forgot to put that comma character as an acceptable linebreak position...


STM should already try and stop punctuation and close-parenthesis from appearing as the first character on a row already: https://twitter.com/KaiClavier/status/1441149108744454155?s=20&t=FLRVtrizJHyAlRE... ...So hopefully that's still formatting Chinese text correctly.


If I see any strange text formatting, I'll refer back to this post, so thank you so much for the detailed explanation! It really helps a lot.

Huh, that's strange, I just tested the script in-editor again and it seems to be working as expected... Are you using an outdated version of STM? OnRebuildEvent was added in v1.8 so you'd have to be using a pretty old version to see an error like that. If the asset store/itch gave you that as a download, I need to get in contact with them! Otherwise, please try updating STM!

Super Text Mesh works with URP and HDRP, but the included outline and dropshadow shaders do not. (They work in a build, but not in-editor)

So for URP/HDRP support, attaching this component to a script will generate the same effect: https://pastebin.com/wWv49mgG

Yeah, even though I'm a native English speaker, I guess rules like this can escape me... but yes usually  "," is followed by a " " anyway! I'll be sure to adjust STM to have the fix for Asian languages in the next upload I do, so I hope everything works for you!

Oh, you're right though, maybe the English "," should be added to the list of linebreak-friendly characters, too? I'm trying to think why i wouldn't have included it on the list in the first place... Feel free to give it a shot, and let me know if you prefer it! Either way, I'mm make sure to push the changes for the next update, so thank you for reporting this!

Ah I see, I must have understood this incorrectly when I added this feature. 


Please go to SuperTextMesh.cs, and on lik 1171, you should see some code that looks like this:

private static List<char> linebreakFriendlyChars = new List<char>(){' ', '\n', '\t', '-', '\u00AD', '\u200A', '\u200B', '。', '〜', '、', ',', '…', '‥', ' '};

If you remove  '、' and  ',' from the list like this...

private static List<char> linebreakFriendlyChars = new List<char>(){' ', '\n', '\t', '-', '\u00AD', '\u200A', '\u200B', '。', '〜', '…', '‥', ' '};

...I believe you should get the results you want. Please let me know if this works as you want, and I'll make sure this functionality is changed!

For this situation, what to do is... when you call Continue(), if it returns true, the text mesh still has text to display, and if it returns false, there's none left with pause tags. I hope this helps!

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.

Ah sorry I was thinking of "StopReadRoutine()" which is a private method. How about... "<e=customEvent><pause>"? So... It calls the custom event that will call continue() on a delay, and pauses at the same time? "Pause" is like... prebaked into how the mesh reads, by the way, just telling the mesh like... "don't bother rendering or parsing the text past this point".

Ah yeah in this situation, I'm going to say stick to using <pause> and Continue(), or use the delay tag. (<d=10>) to delay by 10 imaginary characters being read out. I'm curious what happens if your custom event calls stm.Pause() and then stm.Continue instead, though? Either way, I think the delay tag might be better suited  for this situation!

(1 edit)

Ok, I think I've fixed it! Please send me an email through my website so I can send you an updated version of SuperTextMesh.cs!

Hmm... what version of Unity are you using? and are you using STM with Unity UI, or without? The behaviour upon start is a bit different between the two, so maybe that's why I got different results than you did

In SuperTextMesh.cs, please comment out line 1672! So... please turn this...

}else{
                StopReadRoutine();
                //Debug.Log("Not autoreading");
                SetMesh(0f); //show nothing
            }

into this

}else{
                //StopReadRoutine();
                //Debug.Log("Not autoreading");
                SetMesh(0f); //show nothing
            }

I think my original intent with this code was... If STM has a read delay > 0, but is not set to autoread, stop the read coroutine and set the mesh to be empty. But this stop coroutine call would halt a manual Read() too. I think removing this line should work, so please let me know if it works for you!

Hmm, I'll be able to take a look into this shortly!

For now, I'm curious what the state of autoRead is for this, and if it could be causing a conflict somehow. Do you get the results you want if autoRead is left true, and Read() isn't called? (The behaviour you're trying to do should work regardless, I'm just trying to hunt down the cause and can't open my dev environment at the moment)

Okay, in this scenario, please try...

Make the STM object the child of a layout group.(Horizontal Layout Group, Vertical Layout Group) and set the layout group to have "upper right" child alignment, and uncheck "child focre expand" width and height.

Next, remove the content size fitter component from the STM object, and it should follow the rules of what you want. (Within the bounds of the layout group) Unity Layout stuff works a bit strangely, so apologies for all this. It's a bit weird to set it all up.

Please try attaching a "Content Size Fitter" component to your STM object, and setting "Horizontal Fit" to "Preferred Size" and you should get the result you want!

iirc, the "UI Wrap" and "UI Limit" booleans are holdovers from before I implemented content size fitter, so the toggles are there to change how the two work together. Since... if the text is being set to wrap at it's horizontal limit, but is also being set to it's preferred horizontal size... that would just do nothing anyway. I should probably make it so an "add content size fitter" button pops up if UI Wrap/UI Limit are unchecked and one isn't already attached to STM.

(1 edit)

Ah, nice catch. Turns out that manual pauses were interfering with automatic pauses. I've managed to fix it, and this will work in the next update! (And yes, I see the issue with weird extra hyphens being inserted, too... I'm fixing that right now) EDIT: solved it! I think I'll try and upload these fixes soon, I've got a good amount of them to push, now.

Oh good catch, I never considered that!

Here's a modified script that lets both effects work at the same time! I'll be sure to include it in the next update. https://pastebin.com/LdXhvAuF

I got it working, please check the previous reply! I'm replying here again because I just realized I replied to *myself* yesterday, so you might not have received a notification for it.


Ok, I think I got a solution working! I'm happy with how this component works, here's how it looks in the inspector:


Basically, this allows you to type <link=on>, and it will create or grow colliders in the right spots. </link> can be used to stop a link. You can even define a string to be inserted before a link, so you can have effects applied automatically to clickable text. (<c=blue> in this example) The defined events are copied to colliders that are placed on clickable text.

This system just uses UnityEvents, but the code can be edited for a more robust system for clicking callbacks if needed. 

There's a few scripts for this (works on both Unity UI and without!) so send me an email with your asset store invoice number if you want to try it out early, otherwise I'll include this in the next STM update, which I should hopefully get out soon!

I believe just one line of dialogue in the stage scene uses the link function (it used to be my demo scene for everything before I split it up)

Either way, taking the STMEventInterpreter script and putting it on another STM object should allow the link function to work on any STM object, as long as the prefab is defined. Hopefully I'll be able to add the standalone module soon, but this functionality does work!

Please look at the stage example scene and find the script named "STMEventInterpreter"! It has a custom event (<e2=myEvent>) that's used to spawn a "link" prefab overtop of letters. I believe this is better than any built-in system because it can be customized with any type of overlap method and do anything when clicked. The default prefab spawned uses OnMouseDown() and prints a debug message, and uses the script "STMSampleLink" to do this.


I keep getting this question, so I'll try to make this its own sample scene with a dedicated custom script for the next update! But for the time being I hope this helps.

The closest thing in STM is in the stage example scene - look for the script named "STMEventInterpreter" and it has a custom event within it that can spawn a "link" prefab overtop of letters. Since its a prefab, it can be modified to be any collider type, and do anything you want when clicked! The default prefab just uses OnMouseDown() to send a debug message, and uses the script "STMSampleLink"


I hope this helps!

I'll be sure to add it for the next update! Thank you so much for the help!

Oh, for some reason I was under the impression that "OnRectTransformDimensionsChange()" wouldn't be available since SuperTextMesh doesn't inherit from monobehaviour? Is it actually being called? I'll be able to check myself in a little bit. Thank you so much for your patience, both of you.


I'm not sure why you're getting different results than me, there... did you revert the changes made before?


But if this works, I'll gladly add it to the next update! Even though calling Rebuild() multiple times is inefficient, for small UI elements, which this would mostly be effecting, it's not too bad, even on lightweight platforms. But I keep wondering if there's something else I'm forgetting here, sorry for all the trouble. I'll do another check on the code shortly, but my results look different than yours, so I'm still a bit confused by it all

I got the test scene, and I believe I've solved it...

Please try editing line 1606 of SuperTextMesh.cs to this:

if(uiMode) LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)tr.root);


Using LayoutRebuilder.MarkLayoutForRebuild(tr); almost seems to work here, but when the size changes, you can see it update after a frame... so I think this method might be necessary for now. Hopefully this solves the problem for good?Please let me know, and I'll implement it for the next build!

Oh, I misremembered... a long time ago STM used to use a surface shader instead of a vertex/fragment shader to render, and *that* used emission. (frag/vert just renders the colour directly)

I attempted to rewrite that, so please give this a shot: https://pastebin.com/Dy04z8F5


Let me know how this goes! The shader is pretty simple, so it might not do what you want, just yet.

I believe the default shader already uses emissive to achieve the unlit effect! If you mean that you want text actually emits light that's reflected on the environment (global illumination?)... I'm sure it's possible with a shader, but I've never looked into that type of shader, so I'm not sure where to begin just yet. I just want to clarify we're on the same page before I start editing the shader!

Hmm, what version of Unity are you using? I'm still a bit confused, but maybe I can reproduce the issue in a different version?

Would it be possible to email me this sample project?

...I'm very embarrassed I didn't know about this function, I'll be sure to give it a try soon!


Ok, I tried it out, and I don't think the content size fitter was the solution. Try using the "Layout Element" component on STM. I remade your example scene, and the behaviour seems to be better, even with the code in Update() commented out. But I could still be misunderstanding the issue. (Text is going beyond the UI limit in my gif because I have the cutoff mode set to ignore)



Oh! I understand the issue now, but I'm not 100% sure on the solution just yet.


I'll be able to take a look at this this weekend, but when pressing the "change text" button, before updating STM, please try calling "Canvas.ForceUpdateCanvases()" .

I'm doing a bit more research into this, and it seems that with nested UI elements, the parent element should be set before the child one... so calling layoutGroup.SetLayoutHorizontal(); or layoutGroup.SetLayoutVertical(); before setting STM might also do it. If that works, I'll try to make it so STM checks for this itself when being rebuilt.

I'll keep thinking about the issue, I really want to solve this!

In edit mode, STM will automatically update its internal bounding box when the rectTransform is changed for ease of setting up a UI, but in a build, the bounds need to be manually updated, since the rect sizes will normally only change when enabling a UI, or changing the game's window's size.

Also, try experimenting with adding a "content size fitter" component to the STM object to have it control the horizontal/vertical layout group! It's been a while, but that may produce the results you need. (I could be interpreting the issue incorrectly)

For the window size change, you can call SuperTextMesh.RebuildAll() when changing the window size, and for enabling the UI, make sure the UI gameobject is enabled before your STM object! I tried to write in some automatic fixes for this, but Unity UI can be really fickle about it... You might have to call "Canvas.ForceUpdateCanvases()" before enabling STM if it still remains an issue.


I hope this helps! If these don't work, I'll try to fix it for the next update!

Please send me a screenshot of the entire Unity editor with the Super Text Mesh object selected, and then a screenshot of how it's looking in-game. I won't be able to help without this information.

(1 edit)

Ahh, ok... Yeah hm WaitFrameThenRebuild() was initially added to solve a problem where STM wouldn't Rebuild upon being loaded into a new scene... but the call for UI text under Start()... I wish I commented *why* I set it up like that. My best guess is that I did it to get around an issue with Unity UI refusing to update it's layout, despite calling every possible way to refresh it. If that line is changed to just Rebuild(autoRead) I wonder if that would fix it, without causing the previous UI layout issues to come back...? I might have fixed the aforementioned layout issues in a previous build, but a new Unity UI layout issue always seem to crop up upon fixing an old one.