• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Clinical Encounters

  • Home
  • About
  • Blog
  • Contact
Home › Development › Nightmare Of Text

Nightmare Of Text

Jun 29, 2018 | Ian McKinnon

Sometimes when developing, we run into bugs. Here, one of our programmers details how we approached a bug that was occurring with our text input in the Clinical Encounters platform.


The Issue

For being a unity project, ours is heavily-centered around Canvas and UI work instead of things like 3D or 2D game work. Unity’s built-in text component works pretty well for the most part, but we encountered a strange problem with it. In the editor, every now and again, all text across the program would suddenly transform into a jumbled mess. The program still ran just fine, but with the text unreadable, it was practically unusable. We thought it was simply an editor-only problem, so we ignored it and went on our merry ways since it wasn’t affecting the builds.
Or so we thought.

Not Just an Editor Problem

During some internal testing, somebody had encountered the bug while using a built version of the software. For reference, normal text (Left Rendering) would become jumbled (Right Rendering). Now that we had evidence that the bug could happen in a build, we started to take it seriously.

The first step was to research why something like this was happening. One of the lead programmers on the Clinical Encounters team discovered that it seemed that the reference to the font we used was being updated so it was seemingly outside of an array of given fonts. This would explain why the text was jumbled, but not what caused the de-reference or how to prevent it, so we kept going.

TextMesh Pro was also discovered as an alternative text component. TextMesh Pro is a unity plugin that was picked up by the Unity team a year ago during the reign of Unity 5.5. It has a range of benefits over Unity’s default text and would overall be an upgrade to the text we were using, but the downside was that we would have to replace all of the text across the entire software. This includes replacing the assets, reformatting them, and making sure they look as good as they did before. This would be a big, tedious commitment, so we opted to search for other options unless it was necessary to make the switch.

The Solution

It seemed that the implemented try/catch wasn’t working and the error kept slipping through.

As time went on, we would occasionally encounter the bug here and there. It seemed that the implemented try/catch wasn’t working and the error kept slipping through, so I iterated on the try/catch implementation every time the bug surfaced and we kept on trucking.

Upon looking into it on the code side of things, I discovered that it would happen when a custom script helped our input fields resize as appropriate. Since Unity was showing an error when this would happen I threw the code in a try/catch to see if I could stop this from happening. Unfortunately, none of us knew how to recreate the bug on command, so we simply had to wait to see if it was fixed.

Eventually, we made note of how the bug seemed to happen mostly when Unity lost and regained focus. Before this, the build would pause if the executable window lost focus and would resume when clicked on again. So, we changed the program to run in the background. This definitely reduced the frequency of the bug, but it wasn’t completely solved.

Finally, after a certain iteration of the try/catch and adjusting the line that was throwing the error, I got the catch to work and the error was avoided! I can’t say for sure exactly what the root of the cause was, but it involved referencing the size of the input field and then calculating the new height with that information all on the same line. Separating the current size calculation and when we calculated the new size worked and we haven’t had the bug since.

The Aftermath

Thanks to the discovery of TextMesh Pro, we will be heavily considering it for future projects. We’ve even used it in one place in Clinical Encounters already and it’s been pretty helpful for that. It has some quirks still, but overall it’s a great asset to know about. Having options can be important and can add great flexibility to your development cycle. As for the text issue, we will hopefully never have to encounter something like that again, but we have the tools we will need to handle it if it ever comes up.

You can read more about the Clinical Encounters platform at its website.

Category: Development Tagged: dev-blog game-based learning

Health Impact Studio logo

About Health Impact Studio

We are a dedicated team of developers and researchers with the mission to improve the health of individuals through novel technology including games, virtual reality, and role-playing simulations. We welcome input from the full range of stakeholders to create a customer experience with the broadest applicability to improving health outcomes.

Clinical Tools – Spring 2021 Digital Health Awards® Winner

Jun 8, 2021

Clinical Tools Wins $200K SBIR Award to Decrease Vaping Behavior in Adolescents and Young Adults

Sep 30, 2019

Mindfulness and Patient Communication

Nov 19, 2018

Previous Post: « Managing Case Files
Next Post: Reworking Dialogue »

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Ian McKinnon

Ian is a Unity Programmer working with C# primarily. Ian is a runner, dog lover, gamer, and is a pretty good juggler (The Circus is always his backup plan in life)

More Posts

Primary Sidebar

Keep Reading

  • Clinical Tools – Spring 2021 Digital Hea…
    Jun 8, 2021
  • Clinical Tools Wins $200K SBIR Award to …
    Sep 30, 2019
  • Mindfulness and Patient Communication
    Nov 19, 2018
  • Contact Us
  • Copyright & Reproduction Guidelines
  • Privacy Policy
  • Terms of Service
  • Technology Requirements
  • 508 Compliance

Footer

developed & maintained by
ClinicalTools

The Clinical Encounters Training Group: SBIRT Training | BupPractice | PainTx Challenge | CE:Vaping | CE:Alcohol | CE:Obesity | Lift

Clinical Encounters | Reader

Clinical Encounters | Platform

Group Training

  • Facebook
  • LinkedIn
  • Twitter
clinicaltoolsinc@gmail.com

101 A Market St Chapel Hill, NC 27516
919-960-8118

Contact Us

© 2026 · Clinical Tools, Inc · Log In

Walkthrough of a Clinical Encounters | Decisions Interactive Patient Case

Welcome!

If you have an account, please log in! Or create an account now!

Create an Account!
Log In

Forgot Password?
Register New Account
Don’t have an account?
Register now!
Register
  • Hidden
  • By registering, you agree to the Terms of Service and Privacy Policy. If you are a part of a group, you understand your participation information can be provided to the group organizer.
  • This field is for validation purposes and should be left unchanged.
Sign up for our Newsletter!

Want to keep up to date on HealthImpact.Studio developments? Enter your information below and we’ll let you know when we have new products or open research studies, and what we’re working on for the future.

  • Hidden