yzthr Posted October 24, 2018 Share Posted October 24, 2018 Hello, recently i find that i can't import babylonjs-gui after i import babylonjs with webpack. I don't know why. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted October 24, 2018 Share Posted October 24, 2018 Adding @RaananW who built the modules for babylon and gui. Quote Link to comment Share on other sites More sharing options...
ssaket Posted October 24, 2018 Share Posted October 24, 2018 @yzthr It's because you are not calling/using it anywhere, it would be more helpful if you can show the entire code Also, I am assuming that you have already installed them; anyways adding this for reference (https://doc.babylonjs.com/features/npm_support) Quote Link to comment Share on other sites More sharing options...
yzthr Posted October 24, 2018 Author Share Posted October 24, 2018 Thanks, but i already have called the gui module in my code. and i refer the above reference but i can't find the reason. my code are as follows: when i run the code, chrome shows the following error: @RaananW May u give me some help? thanks Quote Link to comment Share on other sites More sharing options...
ssaket Posted October 24, 2018 Share Posted October 24, 2018 If you import it as "GUI" then use GUI.Control not BABYLON.GUI.Control; otherwise use import { separate classes } form 'babylonjs-gui' or just import 'babylonjs-gui' which will install them in the global BABYLON module and you can use them as BABYLON.GUI yzthr and Sebavan 2 Quote Link to comment Share on other sites More sharing options...
yzthr Posted October 25, 2018 Author Share Posted October 25, 2018 13 hours ago, ssaket said: If you import it as "GUI" then use GUI.Control not BABYLON.GUI.Control; otherwise use import { separate classes } form 'babylonjs-gui' or just import 'babylonjs-gui' which will install them in the global BABYLON module and you can use them as BABYLON.GUI Yes, u're right. but "addControl" is also undefined. Quote Link to comment Share on other sites More sharing options...
JohnK Posted October 25, 2018 Share Posted October 25, 2018 Really need to see the full code again to see what you have changed Quote Link to comment Share on other sites More sharing options...
yzthr Posted October 26, 2018 Author Share Posted October 26, 2018 23 hours ago, JohnK said: Really need to see the full code again to see what you have changed Hi, i have already post the screenshot of the function "createGUI", after that i just call the function once to create the GUI. Sorry for not posting the code cauz the code has not been finished yet. I think it's a bug. Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted October 26, 2018 Share Posted October 26, 2018 Hi, please read the error again. Quote Cannot read property addControl of Undefined it's not "addControl" which is undefined, it's "advancedTexture" which hasn't been created. DylanD 1 Quote Link to comment Share on other sites More sharing options...
JohnK Posted October 26, 2018 Share Posted October 26, 2018 31 minutes ago, yzthr said: Hi, i have already post the screenshot of the function "createGUI", after that i just call the function once to create the GUI. Sorry for not posting the code cauz the code has not been finished yet. I think it's a bug. And what if the error is not in that function? From what @aWeirdo says it is likely to be in the section where you create the advancedTexture. It is always really difficult to help with only part of the picture. DylanD 1 Quote Link to comment Share on other sites More sharing options...
DylanD Posted October 26, 2018 Share Posted October 26, 2018 I agree with aWeirdo and JonhK, it seems, that you reference advancedTexture however it is not defined(there is no instance of the advanced texture) in the function, and it is being referenced locally so if it was defined outside the function it would be in the wrong scope. Here is a playground i threw together: https://www.babylonjs-playground.com/#SNE6BN If this doesnt help try recreating your code in a playground like the one above. 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.