Forum rules - please read before posting.

Issue With Unity UI While Taking Screenshot During Save

I've run into a complication trying to add screenshot capability to my saves. 

The normal save operation involves clicking a button I've added to a save list. After the click, the game is supposed to save and then the save menu closes automatically. This seems to be just included as part of the basic save list functionality. 

Everything works fine without having "Take screenshot when saving" enabled. When I enable it, the save menu fails to close on save and sits over top of everything else I do. I can still click the save buttons and save the game over and over, but the menu never closes. The backdrop menu image closes properly, but everything under the SaveGame canvas I made stays stuck on the screen. 

I can confirm that the game correctly saves and takes a screenshot. If I force close and open the game again the new save file looks and works fine. The only issue is that the save menu won't close after I save. Telling it to close in an actionlist using the after save slot doesn't do anything, and using the check the menu state action fails to detect it as on. 

Let me know if you require any additional details. Thank you for creating this excellent tool! 

Comments

  • In what versions of AC and Unity?  I'm not able to recreate the issue by saving with the default SaveUI prefab, while save screenshots are enabled.

    Are you using the SaveUI prefab included with AC, or a modified/new one?  If modified, switch over to the SaveUI prefab (probably easier to just switch your Menu Manager to Demo_MenuManager and change the Save Menu's Source to Unity Ui Prefab), and let me know if it still occurs.
  • Apologies about the lapse in response here. We are using AC 1.54c and Unity is 5.4.1f1. I did as you requested and swapped in the demo menu manager, which works just fine. So it seems that the problem lies in how our menu manager is set up but I'm unsure what differences might be causing the issue. Back to the drawing board I suppose.
  • What's the Menu's name?  You could try copying over the Demo game's Save menu into your own game, locking your old Save menu and trying that.  If that then works, you'll have isolated the issue down to just that one menu, which should make it easier to find.

    Though the Menu should turn itself off after saving, you can also run an ActionList whenever the game is saved - which you could try using to manually turn it off using the Menu: Change state Action.
  • The menu is called SaveGame. I copied over the demo's save game menu and it did not show the same buggy behavior. I'm having trouble identifying what difference between them could be causing the issue. 

    I specifically ask the menu to change state to turn off using an action list that is called after saving. These actions seem to stick in the hierarchy and don't clear half the time. 
  • Could you post an image of the full ActionList, and the properties you've assigned it, so that I can attempt a recreation?
  • Link to the image: https://drive.google.com/open?id=0B7qOBkrFzrLyRmJHSk94el9kWEE

    Let me know if you want to see the unity ui canvas or anything like that.
  • The Canvas should be fine.  At first glance, I'd say this is due to the Engine: Wait command you have in there.  Any Actions you run after saving must be done immediately - try removing that Action and see if that makes a difference.
  • After removing the Engine: Wait action I started getting stack overflow exceptions and it spammed the close menu action a bunch of times. Probably due to that actionlist being called both on menu close and when a game is saved. I made it so the actionlist is just being called when a game saves which dealt with that problem, but now I'm back at square one with the menu not closing. 

    Except one difference, now the backdrop menu object is also not turning off, so it seems like nothing in the actionlist is running at all, but I can see the actionlist appearing for just a moment in the hierarchy so it seems like saving a game is at least calling it. The problem still goes away when I uncheck the 'Take a screenshot when saving?' option. 
  • You're right - the StackOverflow will be because the ActionList itself is turning off the SaveGame Menu, which as you've said was being run whenever the SaveGame Menu is turned off - causing a loop.

    Is this Backdrop Menu also built with Unity UI?  When a screenshot is taken, AC will automatically disable all UI Canvases for one frame in order to take the screenshot without the UI in the way.  This is likely the source of the conflict, but one thing I wonder: was this ActionList always being run both after saving and upon turning off SaveGame?

    If so, as saving the game also turns off the SaveGame Menu, it would cause this ActionList to be run twice.  Now that you've made it so that it only runs after saving, what effect does re-inserting the Engine: Wait Action have?
  • The Backdrop menu is also created using Unity UI. Previously, yes, the ActionList was always being run in both instances. 

    When I added the Engine: Wait action back in (with the OnMenuClose actionlist only being run on save) the Backdrop menu properly closed but the SaveGame menu is still stuck on the screen. Without the Engine: Wait action both are stuck on the screen.
  • edited January 2017
    All right.  So that I'm completely clear, what is the purpose of this Backdrop Menu?  Is this some graphic you want displayed while the SaveGame menu is open?  If I know exactly what it is you're trying to achieve via these Actions, it'll help me offer an alternative or fix.
  • The Backdrop menu is intended to black out the rest of the screen behind the actual UI that is being displayed. It's just a black image. This was done so each UI canvas could pull double duty ingame as well as in the main menu scene which has been planned out to have a 3d scene that would be covered up if the backdrop was actually part of each canvas. 

    So short answer, yes, we want it displayed when the SaveGame menu is open, but only while accessing it ingame.

    Of course, if this is causing some sort of conflict, we could probably incorporate the backdrop into each UI canvas and check on open whether you're in the main menu scene or not. The current implementation is just how it's been set up for a long while but I have no personal qualms with changing it. 
  • In that case, you could consider moving the backgrop to the same UI, and link it to the Menu Manager via a Graphic element.  Then you'll be able to use the Menu: Change state Action to show/hide the backdrop with the Hide Menu Element / Show Menu Element commands.

    I will still see if a fix can be made for this scenario, however.
  • Thank you for your timely assistance! Do you know if doing so will fix the issue of the other canvas (the SaveGame one) sticking on the screen when save game screenshots are enabled?
  • It may be multiple issues at work, but I will go through and see.
  • I don't know if this is good news or bad news, but I can't actually recreate the problem.  I should have asked this to begin with, but are you using the latest AC?

    I've created a .unitypackage of the test project I made for you to compare with.  Import it, assign the Managers, and run the test scene.  When you press Escape to open the Pause Menu, and navigate to Save, you'll see white Backdrop Menu open as well.  Upon saving, the same ActionList is run (except for the Object: Send message Actions), and all appears to work fine - both Menus close.

    There may be some other factor at work, in which case you may be able to find it by comparing the two.
  • Thanks for looking further into this, I'll try to do a detailed comparison of all the different settings. In the meantime, we are using AC 1.54c. 

    I've done some further messing around and it looks like the SaveGame canvas (backdrop closes just fine) won't even allow a crossfade (activated by clicking a back button) after I've performed a save. 

    Before a save, the SaveGame canvas will crossfade back to our ingame menu just fine, but after the save, it stays stuck on the screen and the ingame menu pops up behind it. If I then disable the SaveGame canvas manually in the Hierarchy and reenable it, I can once again crossfade it until I save another game, which repeats the bug. 

    In other messing around news, I've been digging through the code a bit, looking from SaveData to SaveSystem and now to Menu. There is a function there called PostScreenshotBackup on line 2321 which restores a menu canvas if it was disabled to take a screenshot. Commenting out line 2329, which sets the canvas' gameobject to active if it was a UnityUI and it was flagged as disabled for a screenshot, gets rid of this bug. The SaveGame menu closes fine and saves fine. It even takes the screenshot still. Now, you obviously know this system a lot better than I do. I don't know if commenting out line 2329 in Menu.cs is a good idea or not. 

    My running theory is that the SaveGame menu gets disabled and flagged as disabled for a screenshot because it takes one upon save, then after it should be getting closed it is enabled by this function. So maybe the menu system now thinks it is turned off when it is actually not, which would explain why the Menu: Change State and Menu: Check State can't detect it. Unsure what confluence of actions and things have exactly led to this, but hopefully this is helpful in finding a better solution than hacking out code.   

     
  • My thoughts were along similar lines, though I found it all working on my end.  I would recommend first backing up your project and upgrading to v1.55c, so that we're both working with the same software.

    See if the project I sent works for you, and if so, try to find the key difference.  If all else fails, you can send me your own project for me to investigate.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.