I am trying to make a HUD that displays constantly changing data (distance to enemy, etc.).
I was thinking that using a GUI.Image. In order to do that, I would need to have access to the canvas element where I could update the canvas by hand and then call an .update() like you do with a dynamicTexture texture.
var wallTexture = new BABYLON.DynamicTexture('', someCanvas, scene)
...
// do things to somCanvas
...
wallTexture.update()
Is this a good idea and is it possible?
var image = new BABYLON.GUI.Image("but", "textures/grass.png");
how would I reference the “wallTexture” since it is not attached to a material?
Deltakosh said: well, DynamicTexture internally uses a canvas, so you can set this canvas as the source of your image (or at least directly copy it onto the GUI element)
So I am trying to figure out how to set a GUI.Image source as a DynamicTexture (canvas) but I am getting an error.
First thing is to review how a GUI element draws itself.
Then we jack this and replace what we need!
The one thing you need to do though is set a property on the main container that changes otherwise the image wont draw because the GUI wont see any elements as dirty. In my example that would be the rotation, but you can literally toggle an element like isReady = false, then isReady = true and it will mark it dirty.
@anyone paying attention, can we get a setDirty method?