TextBlock only accept color names.
I would like to know if it is possible to put the value of as in hex as in html
Hey @darkbit!
Welcome to the Babylon family!
Yes you can use hex color values by setting the value to the hex as a string like this:
text1.color = "#0394fc";
Check out this playground for an example:
https://www.babylonjs-playground.com/#XCPP9Y#1513
1 Like
Welcome to the forum!
While the post of @PirateJC actually is the solution of your question regarding TextBlock, for materials colors etc. you may use, for example, RGB from HEX
sphereMat.diffuseColor = new BABYLON.Color3.fromhexstring("#ffffff");
or RGBA from HEX
selectedMaterial.diffuseColor=new BABYLON.Color4.fromhexstring("#FD6304FF");
See also API docs
https://doc.babylonjs.com/api/classes/babylon.color3#fromhexstring
https://doc.babylonjs.com/api/classes/babylon.color4#fromhexstring
2 Likes