🤑 Indie game store🙌 Free games😂 Fun games😨 Horror games
👷 Game development🎨 Assets📚 Comics
🎉 Sales🎁 Bundles

nospoone

7
Posts
1
Topics
A member registered 1 year ago

Recent community posts

All good! Happy that I could solve my text worries :D

I've ended up implementing a bool to toggle the sizing:


As I needed another text to stay a certain size. That bool just replaces the one at line 2510 (that I commented out) and allows me to toggle the feature on or off.

Cheers!

Based on the information above, I was able to make this work by changing the AutoWrap property to this:

private float AutoWrap{ //get autowrap limit OR ui bounds
   get{
      if(uiMode && wrapText) return initialUIAutoWrap; //get wrap limit, within left and right bounds!
      return autoWrap;
   }
}
private float initialUIAutoWrap = 0;

and adding this to OnEnable():

if (uiMode && wrapText) {
   initialUIAutoWrap = ((RectTransform) t).rect.width;
}

which yields the correct sizes in my tests! Success!


I have to figure out the correct padding values, but other than that, it is working! Thanks so much for the help!

(Edited 3 times)
<img src="<a href="https://img.itch.zone/aW1nLzc0MzI5Ny5wbmc=/original/sodrsd.png">https://img.itch.zone/aW1nLzc0MzI5Ny5wbmc=/original/sodrsd.png</a>">RebuildTextInfo

Whoa! Removing that, combined with changing my setting code to:

private void OnDialoguerTextPhase(DialoguerTextData data) {
   RectTransform dialogBoxTextTransform = (RectTransform) DialogBoxText.gameObject.transform;
   DialogBox.SetActive(true);
   DialogBoxText.text = LocalizationManager.GetTermTranslation(data.text);
   DialogBoxText.Rebuild();
   DialogFrame.sizeDelta = dialogBoxTextTransform.sizeDelta;
}

Makes it fit the text. However, how do I define how far it can go before it wraps?

 

Upon further inspection it seems like it makes it fit the longest word? 🤔

---

Edit 1

Looking at SuperTextMesh.cs:

if(uiMode && wrapText) return (float)((RectTransform)t).rect.width; //get wrap limit, within left and right bounds!

Seems like it's not respecting it in some way? Looking further...

---

Edit 2

Seems like AutoWrap gets reset somehow? Calling the code above calls RebuildTextInfo() three times with different AutoSize values:

---

Edit 3

Well, since SetMesh() overwrites the sizeDelta of the RectTransform, it changes the value to the new one (shrunk text), making it impossible to expand it to what it was set initially.

rect.sizeDelta = new Vector2(textMesh.bounds.size.x, textMesh.bounds.size.y);

(Edited 1 time)

Hmm. Using bounds like so:

Vector3 size = DialogBoxText.topLeftBounds - DialogBoxText.bottomRightBounds;

yields correct height, but incorrect width:

I'll try using a VertexMod to get the correct bounds, to see if that works out...

I've been away from updates for so long, forgive me if I've forgotten stuff about my own asset!

No problem whatsoever!

Is it possible to just use the size of the recttransform, itself?

Yes! The problem I had with this, however, is that it stops being updated if/when wrapping is enabled.

Thanks for the tip. I'll try 'em out, I didn't think of them because they said

for non-UI text

However the changelog said they did - I'll try and report back!

To clarify, here's a small and big one side to side:

Ideally, I feed text in and the frame adjusts itself to the size.

(Edited 1 time)

Hi! First of all, thanks for STM - it saved me hours. :D

I am using the uGUI flavor of STM. I am trying to do dialog textboxes where my frame shrinks if the text is small enough (in length), or grows in height once it reaches a maximum width and makes the text wrap. I hope that makes sense.


I can achieve this relatively easily with uGUI by having this setup (which consists of Horizontal Layouts and Content Size Fitters) but I noticed that STM wasn't actually getting its values driven by these components.

That's fine, I thought, I'll just implement the wrapping myself. I have it working, except for one last detail. Here's how I am changing my text:

private void OnDialoguerTextPhase(DialoguerTextData data) {
    RectTransform dialogBoxTexTransform = (RectTransform) DialogBoxText.gameObject.transform;
    DialogBox.SetActive(true);
    DialogBoxText.wrapText = false;
    DialogBoxText.Text = LocalizationManager.GetTermTranslation(data.text);
    if (dialogBoxTexTransform.sizeDelta.x > 500) {
        DialogBoxText.wrapText = true;
        DialogBoxText.Rebuild();
        dialogBoxTexTransform.sizeDelta = new Vector2(500, DialogBoxText.textMesh.bounds.size.y);
    }
}

The problem here is that DialogBoxText.textMesh.bounds  seems to be set to the old bounds, even if I call Rebuild(). It gets updated after two calls to that method.

I've looked through the docs and couldn't find anything of help there... Maybe looping through the characters and identifying the actual mesh size? Do you have any advice on how to make this work?

Thanks again for an awesome asset! :D