So I’m relatively new to PlayCanvas and I want to add a button to my 2D screen.
The code for the button is in an html file called Major.html
It would be helpful if you could tell me how I can make the button appear on the 2D screen
The 2D screen is for use with the Playcanvas UI system. If you would like to add HTML on top of your Playcanvas app, then take a look at the following manual page and tutorial sample:
I just started with game development and I went through these links you sent me.
But I need a little more help understanding what these links are telling me to do
For sure, starting in Game Development can be overwelming. We all have been there. Playcanvas forums are very active and very helpful. So, feel free to post any questions you may have.
Do you have any spesific questions regarding this topic?
@Leonidas
The code I used for the buttons does work. I know that because I ran the code on editors such as repl and atom and it does work. But my teammate and I have been working on this for a day now and we don’t know what we are doing wrong. If you guide us even more that would help.
Sorry for taking so much of you time but please do assist us.
Thank you that definitely helped.
But is there a way where I can see the dropdowns from the button.
There is a dropdown-menu class but it doesn’t work on playcanvas
@Leonidas, I don’t think you’ve noticed the Bootstrap cdn in the HTML code above. No JS code or CSS code is required for the dropdown to work. Is there any other reason that could cause the error?
Yes, if you are adding the functionality from a library you can’t append the library inside the HTML.
You have to include it in your Playcanvas project either by uploading the bootstrap.js file as an asset or loading it manually in code:
You need to do that before attaching your HTML, so bootstrap is already available.
Also make sure to remove the <html>,<head>,<body> elements from your HTML file. Since you aren’t attaching an HTML document, only appending elements to the existing main HTML document (in short you can’t have many <html> elements in the same HTML document).