Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by wuGor · Apr 07, 2018 at 04:52 PM · uitext

Issue with Text Mesh

Hello.

I've got a problem recently when override void OnPopluateMesh. Sometime it print this two errors: alt text 1.Mesh.uv3 is out of bounds.The supplied array needs to be the same size as the Mesh.vertices array UnityEngine.Canvas:SendWillRenderCanvases()

2.Mesh.uv4 is out of bounds.The supplied array needs to be the same size as the Mesh.vertices array UnityEngine.Canvas:SendWillRenderCanvases()

This doesn't happen very often.

When this happens, the text mesh's uv becomes chaos. And this uv problem get right when ui rebuild(I am not sure, but the uv will get right when ui change something ).

I don't know how this problem arose.

Does anybody have any idea about this?

Thank you very much!

Version of Unity: 5.6.3f1 (64-bit)

Here is my code:

 protected override void OnPopulateMesh(VertexHelper toFill)
 {
     if (null == font) return;
     m_DisableFontTextureRebuiltCallback = true;
     Vector2 extents = rectTransform.rect.size;
     var settings = GetGenerationSettings(extents);
     cachedTextGenerator.PopulateWithErrors(text, settings, gameObject);
     IList<UIVertex> verts = cachedTextGenerator.verts;
     float unitsPerPixel = 1 / pixelsPerUnit;
     int charCount = (verts.Count - 4) / 4;
     Vector2 roundingOffset = new Vector2(verts[0].position.x, verts[0].position.y) * unitsPerPixel;
     roundingOffset = PixelAdjustPoint(roundingOffset) - roundingOffset;
     Debug.Log("Populate111");
     toFill.Clear();
 
     UILineInfo[] uiLineInfos = cachedTextGenerator.GetLinesArray();
     ClearLinksBoxs();
     Debug.Log("Populate222");
     InitUnderlineV4();
     Debug.Log("Populate333");
     UpdateEmojis(verts, charCount, uiLineInfos);
     for (int i = 0; i < charCount; i++)
     {
         UIVertex[] charVerts = TextUtil.GetCharVs(verts, i, 4);
         for (int j = 0; j < charVerts.Length; j++)
             charVerts[j].position *= unitsPerPixel;
         if (roundingOffset != Vector2.zero)
             TextUtil.AddOffset(charVerts, new Vector3(roundingOffset.x, roundingOffset.y, 0));
         ELink elink = GetELink(i);
         if (null != elink)
         {
             if (null != elink.data.color)
                 TextUtil.SetColor(charVerts, elink.data.color);
             if (elink.data.interactable)
                 elink.AddBox(charVerts[3].position, TextUtil.GetSize(charVerts));
         }
         if (IfshowEmojiSpr(i))
             TextUtil.ClearUV(charVerts);
         toFill.AddUIVertexQuad(charVerts);
     }
     Debug.Log("Populate444");
     UIVertex[] linesVs = GetLinesVerts(verts, uiLineInfos);
     int lineCount = linesVs.Length / 4;
     Debug.Log("lineCount: " + lineCount);
     for (int i = 0; i < lineCount; i++)
         toFill.AddUIVertexQuad(TextUtil.GetCharVs(linesVs, i, 4));
     Debug.Log("Populate555");
     m_DisableFontTextureRebuiltCallback = false;
     meshPoped = true;
     Debug.Log("Populate666");
 }

When this problem show up, it start with "Populate333"...

alt text

2018-04-08-00-07-40.png (6.9 kB)
snipaste-2018-04-08-01-14-34.png (55.4 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Nathan1258 · Apr 07, 2018 at 04:56 PM

Are you re-using meshes in your code, I had this problem and someone advised me to always create a new one?

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image wuGor · Apr 07, 2018 at 05:25 PM 0
Share

Thank you for your reply! Your answer is very helpful to me. I will check that.

avatar image Nathan1258 wuGor · Apr 07, 2018 at 05:26 PM 0
Share

No problem, text back if it worked or you need more help

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

133 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

UI Text compression on android 1 Answer

Render Debug.Log as UI Text 2 Answers

What's your equivalent of old GUIStyle ? 0 Answers

Canvas is flipping, 2D game 0 Answers

I can't access a values of UIText Component 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges