waverider Posted January 6, 2018 Share Posted January 6, 2018 Hy there, i've been battling with these for hours and i thought i should share, the GUI clears the texture in my scene each time i linked it to more than one model not sure if this is a bug but here's my code: var createUI = function(obj){ // GUI this.obj = null||obj var advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI"); var rect1 = new BABYLON.GUI.Rectangle(); rect1.width = 0.2; rect1.height = "20px"; rect1.cornerRadius = 20; rect1.color = "blue"; rect1.thickness = 4; rect1.background = "silver"; advancedTexture.addControl(rect1); var label = new BABYLON.GUI.Rectangle(); label.width = 0.8; label.height = "10px"; label.cornerRadius = 20; label.thickness = 2; label.background = "green"; rect1.addControl(label); rect1.linkWithMesh(this.obj); rect1.linkOffsetY = -50; rect1.alpha = 1 return rect1; } Quote Link to comment Share on other sites More sharing options...
Gijs Posted January 6, 2018 Share Posted January 6, 2018 The documentation says you can only have 1 FullscreenUI per scene, so maybe try putting var advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI"); outside the function waverider and Pryme8 2 Quote Link to comment Share on other sites More sharing options...
waverider Posted January 6, 2018 Author Share Posted January 6, 2018 THANKS WHAT A RELIEF! works fine now! Gijs 1 Quote Link to comment Share on other sites More sharing options...
waverider Posted January 7, 2018 Author Share Posted January 7, 2018 I changed the scale of my rendering canvas but the pointer coordinate somehow gets messed up. how can i set the pointer coordinate for buttons, here's my code: var coord = new BABYLON.Vector2(scene.pointerX/4, scene.pointerY/4).normalize() button1._onPointerDown = function(button1, coord){ console.log(coord) } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.