# AdvancedDynamicTexture.CreateForMesh Sometimes it doesn't work

**URL:** <https://forum.babylonjs.com/t/advanceddynamictexture-createformesh-sometimes-it-doesnt-work/36996>\
**Category:** Questions\
**Tags:** gui, material\
**Created:** [December 30, 2022, 7:34am UTC](https://forum.babylonjs.com/t/advanceddynamictexture-createformesh-sometimes-it-doesnt-work/36996 "2022-12-30T07:34:47Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Knifepro](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/knifepro/32/39429_2.png) [@Knifepro](https://forum.babylonjs.com/u/Knifepro)\
**Post date:** [December 30, 2022, 7:34am UTC](https://forum.babylonjs.com/t/advanceddynamictexture-createformesh-sometimes-it-doesnt-work/36996/1 "2022-12-30T07:34:47Z")

</div>

Hello everyone, I have a problem that I can’t always find a solution to, I use the codes as I will give in the link below, but sometimes the texts overlap in a very ridiculous way, like in the example image, how can I solve this problem? is there an error in my code or is my code missing?  
note i am using version 5.10.

> **[Babylon.js Playground](https://playground.babylonjs.com/#TMHF80%231707)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/6/6/664267c7bb550afd5163334ef5e3b90c4f4503f9.png)

---

<div class="post-metadata">

**Author:** ![Knifepro](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/knifepro/32/39429_2.png) [@Knifepro](https://forum.babylonjs.com/u/Knifepro)\
**Post date:** [December 30, 2022, 8:08am UTC](https://forum.babylonjs.com/t/advanceddynamictexture-createformesh-sometimes-it-doesnt-work/36996/2 "2022-12-30T08:08:55Z")

</div>

LINK UPDATE =\> [https://playground.babylonjs.com/#TMHF80#1707](https://playground.babylonjs.com/#TMHF80#1707)

---

<div class="post-metadata">

**Author:** ![musk](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/musk/32/17156_2.png) [@musk](https://forum.babylonjs.com/u/musk)\
**Post date:** [December 30, 2022, 8:32am UTC](https://forum.babylonjs.com/t/advanceddynamictexture-createformesh-sometimes-it-doesnt-work/36996/3 "2022-12-30T08:32:11Z")

</div>

I guess the overlap is because you have multiple textblocks, but you didn’t set top for them  
[Size Plane Based on Dynamic Texture | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#TMHF80#1712)

---

<div class="post-metadata">

**Author:** ![Knifepro](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/knifepro/32/39429_2.png) [@Knifepro](https://forum.babylonjs.com/u/Knifepro)\
**Post date:** [December 30, 2022, 8:38am UTC](https://forum.babylonjs.com/t/advanceddynamictexture-createformesh-sometimes-it-doesnt-work/36996/4 "2022-12-30T08:38:28Z")

</div>

By the way, I started having this problem after I upgraded from 5.0.3 beta to 5.10.0, is there a change in the GUI library between these versions?

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [December 30, 2022, 10:03am UTC](https://forum.babylonjs.com/t/advanceddynamictexture-createformesh-sometimes-it-doesnt-work/36996/5 "2022-12-30T10:03:17Z")

</div>

> [@Knifepro](#):
>
> I started having this problem after I upgraded from 5.0.3 beta to 5.10.0

Hum. Not sure about that. According to the doc, the ADT needs a resolution. When I read ‘resolution’ I understand expressed in pixels and this is the only way I have ever used it. Pinging @carolhmj

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [December 30, 2022, 10:45am UTC](https://forum.babylonjs.com/t/advanceddynamictexture-createformesh-sometimes-it-doesnt-work/36996/6 "2022-12-30T10:45:02Z")

</div>

Yep it’s in pixels. I’m not really sure what’s the problem in the linked playgrounds as it looks like normal text to me? I see that the texture scale and angles were changed too so I’d probably change it back to see the default state.

---

<div class="post-metadata">

**Author:** ![Knifepro](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/knifepro/32/39429_2.png) [@Knifepro](https://forum.babylonjs.com/u/Knifepro)\
**Post date:** [December 30, 2022, 11:09am UTC](https://forum.babylonjs.com/t/advanceddynamictexture-createformesh-sometimes-it-doesnt-work/36996/7 "2022-12-30T11:09:45Z")

</div>

The strange thing is that if I say I write 100 times, only 4-5 of them have problems and it drives me crazy, if you say that this is not a problem, I will understand you 🙂

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [December 30, 2022, 11:30am UTC](https://forum.babylonjs.com/t/advanceddynamictexture-createformesh-sometimes-it-doesnt-work/36996/8 "2022-12-30T11:30:18Z")

</div>

When you say “write” 100 times, do you mean running the playground 100 times? This exact same playground? It’s hard to say if it’s a problem or not if I can’t see it 🙂

---

<div class="post-metadata">

**Author:** ![Knifepro](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/knifepro/32/39429_2.png) [@Knifepro](https://forum.babylonjs.com/u/Knifepro)\
**Post date:** [December 30, 2022, 11:37am UTC](https://forum.babylonjs.com/t/advanceddynamictexture-createformesh-sometimes-it-doesnt-work/36996/9 "2022-12-30T11:37:42Z")

</div>

No no it’s a mistake due to my misrepresentation  
I wanted to specify the rate of getting this error in my own react project.  
That’s why I was hovering over the version anyway, as a last resort, I’m going to install the latest version.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [December 30, 2022, 11:42am UTC](https://forum.babylonjs.com/t/advanceddynamictexture-createformesh-sometimes-it-doesnt-work/36996/10 "2022-12-30T11:42:24Z")

</div>

Hmm if you can’t reproduce this error on the playground then we would need to see your react project, and there’s a lot that can be causing this on the react side too

---

<div class="post-metadata">

**Author:** ![Knifepro](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/knifepro/32/39429_2.png) [@Knifepro](https://forum.babylonjs.com/u/Knifepro)\
**Post date:** [December 30, 2022, 11:44am UTC](https://forum.babylonjs.com/t/advanceddynamictexture-createformesh-sometimes-it-doesnt-work/36996/11 "2022-12-30T11:44:43Z")

</div>

I can send you a little demo for the codes

---

<div class="post-metadata">

**Author:** ![Knifepro](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/knifepro/32/39429_2.png) [@Knifepro](https://forum.babylonjs.com/u/Knifepro)\
**Post date:** [December 30, 2022, 11:52am UTC](https://forum.babylonjs.com/t/advanceddynamictexture-createformesh-sometimes-it-doesnt-work/36996/12 "2022-12-30T11:52:11Z")

</div>

```
window.standLoader = SceneLoader.ImportMesh("", "/assets/", gltfName, scene, (meshes) => {
			meshes[0].name = "mymesh";
			meshes[0].scaling.x = 100.0;
			meshes[0].scaling.y = 100.0;
			meshes[0].scaling.z = -100.0;
			for (var i = 0; i < meshes.length; i++) {
				if (meshes[i].name.indexOf("text") > -1) {
					if (window.content[meshes[i].name]) {
						textReplace(scene, meshes[i].name, window.content[meshes[i].name], window.content[meshes[i].name + "_options"], meshes[i]);
					}
				}
			}
		});

```

---

<div class="post-metadata">

**Author:** ![Knifepro](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/knifepro/32/39429_2.png) [@Knifepro](https://forum.babylonjs.com/u/Knifepro)\
**Post date:** [December 30, 2022, 11:53am UTC](https://forum.babylonjs.com/t/advanceddynamictexture-createformesh-sometimes-it-doesnt-work/36996/13 "2022-12-30T11:53:08Z")

</div>

I also shared the codes written in the textReplace function above in the playground.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [December 30, 2022, 2:46pm UTC](https://forum.babylonjs.com/t/advanceddynamictexture-createformesh-sometimes-it-doesnt-work/36996/14 "2022-12-30T14:46:28Z")

</div>

Yeah there’s a lot that can go wrong there, like this window.content object since it’s a global window object it can not get cleaned between refreshes and mess up the logic

---

<div class="post-metadata">

**Author:** ![Knifepro](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/knifepro/32/39429_2.png) [@Knifepro](https://forum.babylonjs.com/u/Knifepro)\
**Post date:** [January 2, 2023, 7:18am UTC](https://forum.babylonjs.com/t/advanceddynamictexture-createformesh-sometimes-it-doesnt-work/36996/15 "2023-01-02T07:18:17Z")

</div>

Do you think I should send it as a pointer inside the function?
