Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Cwal on August 31, 2015, 06:09:43 PM

Title: UILabels breaking
Post by: Cwal on August 31, 2015, 06:09:43 PM
I have a project that I upgraded to NGUI 3.9.2, and every time I change the font size on a label that is set to shrink content, I get a series of error messages that "Destroying GameObjects immediately is not permitted during physics trigger/contact, animation event callbacks or OnValidate. You must use Destroy instead." and the text gets stuck on the screen.  It seems to happen most consistently when the font size becomes greater than the height of the box.

I also get "NullReferenceException: Object reference not set to an instance of an object
UIDrawCall.CreateMaterial () (at Assets/NGUI/Scripts/Internal/UIDrawCall.cs:260)
UIDrawCall.RebuildMaterial () (at Assets/NGUI/Scripts/Internal/UIDrawCall.cs:348)
UIDrawCall.UpdateMaterials () (at Assets/NGUI/Scripts/Internal/UIDrawCall.cs:368)
UIDrawCall.OnWillRenderObject () (at Assets/NGUI/Scripts/Internal/UIDrawCall.cs:568)
UnityEditor.DockArea:OnGUI()"

when playing the scene after one of these errors occurs.
This is preventing me from rebuilding my UI, any help would be appreciated.
Title: Re: UILabels breaking
Post by: ArenMook on September 06, 2015, 05:03:01 PM
Do you have something being called from within a physics or animation callback? That's what the error is pointing to. The null exception is likely caused by the first error in your case.
Title: Re: UILabels breaking
Post by: dxball on September 07, 2015, 07:55:09 PM
Hi, I'm facing the same problem.

I'm using Unity 5.1.3f1 & NGUI 3.9.2

I made a repo video to show this issue

https://youtu.be/pACjnQYzic8 (https://youtu.be/pACjnQYzic8)
Title: Re: UILabels breaking
Post by: siavash on September 09, 2015, 11:10:16 PM
We also faced the same issue in our project (Unity 5.1.3f1 , NGUI 3.9.2) . The text UIlabel crashes ,sometimes doesn't show the text at all so We had to turn it off and on by code.Another problem that we are facing is that the UI label position & size changes suddendly during the game  .
https://www.dropbox.com/s/ene1lvxtpa2ye27/Screenshot%202015-09-10%2011.35.50.png?dl=0
Title: Re: UILabels breaking
Post by: sean on September 12, 2015, 01:21:28 AM
Yes, I got this problem too. Is this a bug of version 3.9.2?
Title: Re: UILabels breaking
Post by: ArenMook on September 13, 2015, 06:14:02 AM
Can one of you create a repro case for me to look at that exhibits this issue? I don't have this happening on my end so I can't fix it properly. However you can just add null checks on line 260 and 287:
  1. mClipCount = (panel != null) ? panel.clipCount : 0;
  1. if (panel != null && panel.clipping == Clipping.TextureMask)
Title: Re: UILabels breaking
Post by: dxball on September 13, 2015, 07:42:03 PM
Can one of you create a repro case for me to look at that exhibits this issue? I don't have this happening on my end so I can't fix it properly. However you can just add null checks on line 260 and 287:
  1. mClipCount = (panel != null) ? panel.clipCount : 0;
  1. if (panel != null && panel.clipping == Clipping.TextureMask)
Hi
The vidoe I made is just a new project created by Unity 5.1.3
import NGUI from Assets/Custom Package/ -> Find NGUI Package in Path "C:\Users\[login account]\AppData\Roaming\Unity\Asset Store-5.x\Tasharen Entertainment\Editor ExtensionsGUI\"

If the UILable use Unity Font and change the font size in unity inspector quickly, the issue will happen


-- edit

I just add the fixed code to the repo project, but this issue still happen  :-X
Title: Re: UILabels breaking
Post by: ArenMook on September 20, 2015, 01:22:23 AM
Add another early exit to UpdateMaterials() function in UIDrawCall.cs, line 364:
  1.         void UpdateMaterials ()
  2.         {
  3.                 if (panel == null) return; // <-- here
  4.  
  5.                 // If clipping should be used, we need to find a replacement shader
  6. ...
Title: Re: UILabels breaking
Post by: MrNoobin on September 22, 2015, 08:13:43 PM
Add another early exit to UpdateMaterials() function in UIDrawCall.cs, line 364:
  1.         void UpdateMaterials ()
  2.         {
  3.                 if (panel == null) return; // <-- here
  4.  
  5.                 // If clipping should be used, we need to find a replacement shader
  6. ...

Ran into the same issue. All your posts on this thread fixed it for me. Thank you!
Title: Re: UILabels breaking
Post by: shaunpeoples on September 23, 2015, 10:06:27 AM
Saw this issue, changed code, then had the editor complain that Destroy can't be used in Editor. Created all manner of trouble with dynamic fonts.
Title: Re: UILabels breaking
Post by: justinISO on September 23, 2015, 01:04:57 PM
Following. I am seeing this same issue.
Title: Re: UILabels breaking
Post by: dafunker on September 28, 2015, 07:05:03 AM
http://www.tasharen.com/forum/index.php?topic=13608.msg60986#new