2D Toolkit Forum
2D Toolkit => Support => Topic started by: xfa27 on September 14, 2013, 06:33:24 pm
-
Hi unikron,
Currently using 2d toolkit for my game. I got this strange problem when updating a tk2dtextmesh using tk2dtextmesh.Commit(), after assigning text from a int variable using tk2dtextmesh.text = (int variable).toString();
Sometimes it works, but after a few tries it returns a null reference exception, and after that it won't work anymore.
I'm currently calling the assigning and commit code using a event-delegate method. the text is a tk2dtextmesh in a scene that is assigned to the update script via drag and drop from the scene.
Here's the code : (note some name are replaced with ~ for privacy)
NullReferenceException
at UnityEngine.Component.GetComponent[MeshFilter] () [0x00000] in <filename unknown>:0
at tk2dTextMesh.Init () [0x00277] in /Volumes/Temp/~/TK2DROOT/tk2d/Code/Fonts/tk2dTextMesh.cs:505
at tk2dTextMesh.Commit () [0x0002f] in /Volumes/Temp/~Assets/TK2DROOT/tk2d/Code/Fonts/tk2dTextMesh.cs:546
at (wrapper delegate-invoke) EventsController/~Handler:invoke_void__this__ ()
at (wrapper delegate-invoke)
-
Hi. How is your scene set up?
Do you have nested prefabs? There is a bug in Unity that resets objects in nested prefabs which could potentially cause this. Also, where is the delegate being called from?
-
Hi,
I don't have any nested prefab. All i did is just put a button prefab inside a tk2dcamera anchor.
Can I ask for your email ? It might be easier to send you a sample scene. What's odd is that it works at the beginning, but after a few times it just stop working and only work if the app is reinstalled.
-
You can send your package to support at unikronsoftware.com
-
Hi,
Back on this. I am unable to duplicate it on a simplified project. It was quite a complex scene with multiple camera anchor but without any prefab (it was a score screen). The error happened when I combined using prime31 social networking, and I want to update the screen after a successful social post. It then will only happen after several times..
I don't know if this is unity bug or 2d toolkit bug, but right now I redone the entire scene simplified totally, and it works fine now. Thanks for the quick support and reply.