Forum rules - please read before posting.

Load Game is setting menu as inactive

Hi Chris,
I am facing an issue with save/load that maybe you can assist with.
I have an inventory item "Diary" that calls an asset (action) to open and close diary.
Because I need to query the Diary UI object and Unity doesn't let me query inactive objects I make the menu active on start but with a Canvas Group and alpha 0.
Then my action acts as a toggle that toggles between an alpha 0 and 1 effectively hiding and showing my diary. Great.
The issue is that for some reason when I load a game, the Diary appears as inactive. I have no idea why that is since nothing from my side is inactivating that object.
Do you have any idea why this might be happening? Is there anything that inactivates a menu on load game in AC?
Cheers,

Comments

  • Is this diary linked to AC's Menu system?

    AC will disable/enable linked UI Canvases upon loading according to their internal "on" state.  So if a Menu is considered "off", but you've manually enabled it, then AC will still believe it to be off and will have it disabled after loading.

    What is its Appear type set to?  Try setting it to Manual and checking Enabled on start?.  Alternatively, you could hook into the PostLoad call and manually enable it again.
  • Hi Chris,
    Yes it is linked to AC's menu system.
    The appear is already set as Manual with "enabled on start" and it works fine in the beggining (it does start as enabled) but after loading that setting seems to be getting ignored.
    I might look into that PostLoad hook then.
    Thanks!
  • Hi Chris,
    I have to say I still don't get why this happens.
    I used Postload hook and that works fine but I just want to confirm if this is the best practice.
    Cheers,
  • Well, it is a bit of a hack - but that's because you're modifying your UI in a way that is unintended.

    AC wants to disable the Canvas of any inactive Menus, but you're instead keeping it on and making it invisible.

    Game dev inevitably relies on the odd hack, so I wouldn't be too concerned about it - but if you want to really make it "best practice" then I'd suggest moving whatever data you're referring to in the UI onto a separate GameObject so that you can read it regardless of the Canvas's enabled state.
  • Hi Chris,
    That's a good suggestion thanks.
    I will have a look at that.
    Cheers,
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.