waverider

GUI clears texture

Recommended Posts

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;

}

 

Share this post


Link to post
Share on other sites

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)
    }

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.