Black Screen after being Published

Hi! I published one scene however, it won’t load and I could only see a black screen. Here’s a screenshot of what I can see and my editor that shows what I’m supposed to see when I publish it. I only hav one scene and I don’t know what causes it. What should I do to fix this?

Do you see any errors in console? What can you see in Launcher?

Hi! I can see it in the Launcher but whenever I publish it, it’s all black. Here are the errors in the console

@yak32 any ideas?

Can you share the link to the published build? Almost looks like an error with the loading script or something else in your project scripts.

When you load the launch tab in the editor, do you have any errors in the console? If so, you must fix them as in a published build, all the scripts are merged into one file. An error would stop the rest of the code in the file from executing. Whereas in the launch tab, each script is still loaded individually and an error would only affect that script file alone.

Hi! Thank you, I actually resolved it already and was able to fix the error. I can already see the published, however, some of my buttons won’t work even though it works well when I launch it individually. Do you perhaps know what causes the button to not work properly?

Check the dev console for errors and debug through the minified code (or publish with source maps so you can debug more effectively).

What is a minified code? Why are the buttons working properly when launch individually but can’t proceed continuously when publish?

What do you mean by launching individually? Sounds like your game doesn’t have a logic to switch the buttons. You need to launch only once and the game scripts should handle buttons and screens switching.

As in, you will need to debug your published build to see where the code is failing to perform some action when the buttons are clicked. And the code is minified when published so you will be debugging in that that unless you tick ‘include sourcemaps’ when publishing from PlayCanvas Editor

The buttons are used to teleport the position of the camera. In testing the buttons, I have to move the camera manually to where a specific button is located, that’s what I meant when I launch it individually. All the buttons are attributes in one script attached to the Root. I hope you can help me. Here is my code

var LevelComplete = pc.createScript('levelComplete');

LevelComplete.attributes.add('cameraEntity', {type: 'entity'});
LevelComplete.attributes.add('Play', {type: 'entity'});
LevelComplete.attributes.add('Next', {type: 'entity'});
LevelComplete.attributes.add('nextClyde', {type: 'entity'});
LevelComplete.attributes.add('nextEmber', {type: 'entity'});
LevelComplete.attributes.add('nextEve', {type: 'entity'});
LevelComplete.attributes.add('walkingEve', {type: 'entity'});
LevelComplete.attributes.add('nextLucia', {type: 'entity'});
LevelComplete.attributes.add('nextLouie', {type: 'entity'});
LevelComplete.attributes.add('nextEzy', {type: 'entity'});
LevelComplete.attributes.add('nextCass', {type: 'entity'});
LevelComplete.attributes.add('PlayAgain', {type: 'entity'});

// initialize code called once per entity
LevelComplete.prototype.initialize = function() {
   LevelComplete.instance = this;

  this.Play.button.on('click', function(){

     this.cameraEntity.rigidbody.teleport(-27, 12, 30);

    }, this);

    this.Next.button.on('click', function(){

     this.cameraEntity.rigidbody.teleport(35, 12, 30);

    }, this);

  this.nextClyde.button.on('click', function(){

     this.cameraEntity.rigidbody.teleport(172, 12, 30);

    }, this);
  this.nextEmber.button.on('click', function(){

     this.cameraEntity.rigidbody.teleport(311, 12, 30);

   }, this);

   this.nextEve.button.on('click', function(){

     this.cameraEntity.rigidbody.teleport(427, 12, 30);

   }, this);

   this.walkingEve.button.on('click', function(){

     this.cameraEntity.rigidbody.teleport(549, 12, 30);

   }, this);

   this.nextLucia.button.on('click', function(){

     this.cameraEntity.rigidbody.teleport(601, 12, 30);

   }, this);

   this.nextLouie.button.on('click', function(){

     this.cameraEntity.rigidbody.teleport(711, 12, 30);

   }, this);

   this.nextEzy.button.on('click', function(){

     this.cameraEntity.rigidbody.teleport(847, 12, 30);

   }, this);

   this.nextCass.button.on('click', function(){

     this.cameraEntity.rigidbody.teleport(988, 12, 30);

   }, this);

   this.PlayAgain.button.on('click', function(){

     this.cameraEntity.rigidbody.teleport(-25, 12, 30);

    }, this);

In the published build, open the browser debugger and add breakpoints to the button callbacks to see if they are being called. If not, then it’s likely that the initialize function is not being called here due to a previous error.

If you share the link to your published build, it be a lot easier to help you

Here is the link of my published build. Thank you!

I get stuck on this screen and the code looks odd

You set timeout for functions on EVERY update, why is this?

If you haven’t yet, I would recommend completing starter tutorials to get familiar with how to set up your scene and control the logic. You can start with Keepy Up:

There was another one somewhere, but I can never find it. @yaustar do you happen to have the link to that other tutorial? We should add it to tutorials, like Keepy Up.

Are you thinking of the crash course? It’s under the basics tag Tutorials | PlayCanvas Developer Site

1 Like