Search Unity

Black Game Screen on exiting Unity Ads, but works fine in editor window

Discussion in 'Unity Ads & User Acquisition' started by a_deo_et_rege, May 16, 2018.

Thread Status:
Not open for further replies.
  1. a_deo_et_rege

    a_deo_et_rege

    Joined:
    Jun 13, 2017
    Posts:
    13
    I am trying to implement unity ads through a button on the pause menu, this all works but when the CLOSE button is pressed, once the ad has finished the game screen returns a black screen with nothing showing.

    But with the editor window open while playing everything is showing and displaying correctly in the editor window, it even picks up the button presses and works as it should but its just not showing in the game window

    The pause menu works by pressing the escape key, the ads are started by pressing a button in the pause menu. Having read up on the ads system i think it does something similar to the pause function i am using, but the fact it works in the editor window makes me think this is not the issue, the pause script is below:

    Any help or advice would be greatly appreciated, i am very new to coding being from an art background.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PauseTheGame : MonoBehaviour {
    5.     public Transform canvas;
    6.  
    7.     // Update is called once per frame
    8.     void Update () {
    9.         if (Input.GetKeyDown(KeyCode.Escape))
    10.         {
    11.             Pause();
    12.         }
    13.     }
    14.     public void Pause()
    15.     {
    16.         if (canvas.gameObject.activeInHierarchy == false)
    17.         {
    18.             canvas.gameObject.SetActive(true);
    19.             Time.timeScale = 0;
    20.             AudioListener.pause = true;
    21.  
    22.         }
    23.         else
    24.         {
    25.             canvas.gameObject.SetActive(false);
    26.             Time.timeScale = 1;
    27.             AudioListener.pause = false;
    28.         }
    29.     }
    30. }
     
  2. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
  3. a_deo_et_rege

    a_deo_et_rege

    Joined:
    Jun 13, 2017
    Posts:
    13
    Hi Rasmus thanks for replying.

    Initially i am testing in unity and experience the black screen problem as mentioned, with the scene view open at the same time I can see the game is working this is just not displayed in the Game View which shows a black screen.

    The screen shot attached shows this, any button presses or mouse clicks in the game view can be seen working in the Scene View, but in the game view its a black screen.

    I have tested on android using build and run, which does show the black screen but as i have no scene window for the device i cannot see anything working like it does when played inside unity.
     

    Attached Files:

  4. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    What is the purpose of this custom Pause functionality? Ads SDK handles pausing the game while the ad is being shown.

    /Rasmus
     
  5. a_deo_et_rege

    a_deo_et_rege

    Joined:
    Jun 13, 2017
    Posts:
    13
    Hi Rasmus

    This is just a normal pause game menu, to allow the player to quit game or return to main screen.

    I am trying to incorporate the ability to also play ads from here.

    As mentioned this works in the scene view whilst the game is playing, pressing ESC brings up the pause menu and then selecting Play Ad results in the testing ads being launched and playing. But pressing close from the ad when it is finished returns to a black screen in the game view.

    Even though the game view is black when pressing ESC again I can see in the Scene view it returning to the game and it playing.

    Hope this helps and really appreciate your help :)
     
  6. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    But won't setting Time.timeScale = 0 effectively make your game non-responsive, which could lead to the black screen? Have you tried showing Ads when game isn't paused?

    /Rasmus
     
  7. a_deo_et_rege

    a_deo_et_rege

    Joined:
    Jun 13, 2017
    Posts:
    13
    I have managed to get the ads working and returning back to the game screen outside of the pause menu yes.

    What confuses me is the fact that it will work in the scene view even though the game screen is black when implemented within the pause menu.
     
    Last edited: May 16, 2018
  8. DIMA699

    DIMA699

    Joined:
    May 20, 2018
    Posts:
    1
    [QUOTE = "a_deo_et_rege, post: 3499024, member: 1413797"] мне удалось заставить рекламу работать и вернуться на экран игры за пределами меню паузы да.

    Что меня смущает, так это то, что он будет работать в режиме просмотра сцены, даже если экран игры черный, когда он реализован в меню паузы.[/ЦИТАТА]
    помоги мне,как ты убрал чёрный экран?????
     
  9. a_deo_et_rege

    a_deo_et_rege

    Joined:
    Jun 13, 2017
    Posts:
    13

    - Hi Dima699 - Sorry had to google translate, i didnt resolve the issue as I couldnt find a work around, I have had to implement it out side of the pause menu
    In Russian -
    Извините, пришлось перевести Google, я не решил проблему, так как я не мог найти работу, мне пришлось реализовать ее на стороне меню паузы
     
  10. maiyoulian

    maiyoulian

    Joined:
    Apr 13, 2019
    Posts:
    1
    Hi I'm experiencing the same problem as well. I made a pause function by setting Time. timescale to 0. It works fine when I tested it on my unity editor, but when I build and run it on my android device everything went black except for my UI when I pause the game and it remains black when I unpause the game. Is it some build setting that has problem?
     
  11. Cloud-Yo

    Cloud-Yo

    Joined:
    Sep 5, 2014
    Posts:
    12
    I'm having a similar issue on Unity 2020.3.25f1 . In my case, I have a menu scene and a game scene. When I play a rewarded ad in the game scene and the ad closes with the x, I get a flash of my Menu scene before the game snaps back to the actual scene. I am also implementing a time scale of 0 since my game has a continuous timer that I wish to pause while the player watches an ad.
     
  12. Unity_Quinn

    Unity_Quinn

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    102
    Hi @Cloud-Yo,

    Thanks for reporting this. Would you mind creating a ticket with us directly by emailing unityads-support@unity3d.com with a video of the flash you're seeing so that we can investigate further?

    Have you tried showing ads without changing the time scale? I've just added a timer to my test project, and it seems that the Unity Ads SDK is pausing the timer automatically while the ad is being shown. Perhaps we've implemented our timers differently? It's probably worth including the code you are using to implement the timer and your Unity Ads integration code in the support ticket, and we'll be happy to take a look. :)

    Have a great day!
     
  13. Cloud-Yo

    Cloud-Yo

    Joined:
    Sep 5, 2014
    Posts:
    12
    My timer is running off of a TimerManager's Update. I play sounds to "tick" down the last 3 seconds and if I don't set the timescale to 0 I will hear the timer reset in the BG during an ad. Before I make the PlayRewardedAd call, I set an overlaid UI image to active(just a black image) to cover the screen, once I get the callback from a successful ad I animate that image's alpha to fade out. In the Editor, it works as expected, on my device the screen flashes the Menu scene (not the current scene) then the black image for an instant and it finally snaps back to the current scene's camera. No fading.

    Ill go ahead and submit the video as you recommended. Thanks!
     
Thread Status:
Not open for further replies.