Author Topic: Typewriter component flashes full text before activating  (Read 1920 times)

Disastercake

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 87
  • www.disastercake.com
    • View Profile
    • Disastercake
Typewriter component flashes full text before activating
« on: September 30, 2014, 10:55:56 PM »
I'm having a graphical bug where the text in a label with a TypewriterEffect component attached will flash when new text is added before the typewriter takes effect.

I currently use this:
  1. TypeWriterComp.ResetToBeginning();
  2. TypeWriterComp.enabled = true;
  3. TextLabel.text = "Hello World";
  4.  

I've also tried
  1. TypeWriterComp.enabled = true;
  2. TextLabel.text = "Hello World";
  3. TypeWriterComp.ResetToBeginning();
  4.  

With the above code, "Hello World" will display for a split second, but then disappear as the TypewriterEffect begins working as intended.

What is the proper way to use the TypewriterEffect component so that text is not shown until the typewriter begins?
Creator of Soul Saga.
http://www.disastercake.com

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Typewriter component flashes full text before activating
« Reply #1 on: October 01, 2014, 05:11:22 PM »
ResetToBeginning() should be enough, provided you're on the latest version of NGUI. You can try changing TypewriterEffect's ResetToBeginning() function to also call Update() at the end, see if that helps.
  1.         public void ResetToBeginning ()
  2.         {
  3.                 Finish();
  4.                 mReset = true;
  5.                 mActive = true;
  6.                 mNextChar = 0f;
  7.                 mCurrentOffset = 0;
  8.                 Update();
  9.         }

Disastercake

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 87
  • www.disastercake.com
    • View Profile
    • Disastercake
Re: Typewriter component flashes full text before activating
« Reply #2 on: October 02, 2014, 01:45:12 AM »
Adding update() to that method works perfectly!

With that edit, setting the text first then ResetToBeginning() works exactly as intended:
  1. TextLabel.text = "Hello World";
  2. TypeWriterComp.ResetToBeginning();
  3.  

If you could, it would be great if you could add that to it in the next NGUI update so it doesn't have to be fixed manually each update.

Thank you very much, ArenMook!
Creator of Soul Saga.
http://www.disastercake.com

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Typewriter component flashes full text before activating
« Reply #3 on: October 02, 2014, 10:10:54 PM »
Yup, done.