Forum rules - please read before posting.

Refresh Aspect Ratio?

edited June 2023 in Technical Q&A

Hello Chris, I'm noticing a weird behavior with aspect-ratio. (I've set it in the settings to be fixed 1.7777).
All works good if I change it in-game (via Pause menu) or from Main Menu.
So the forced aspect-ratio is actually working. But, it doesn't apply when I change resolution via saved options...
Let me explain better:

  • I'm not relying at all on PlayerPrefs.
  • The options are stored on my saved game file.
  • If I change resolution on Main Menu, for instance to a 4:3 aspect ratio resolution (i.e. 1280x960), I see it correctly on the Main Menu. If I change resolution on Pause Menu during a gameplay, I see it correctly.
  • The problem happens when I change resolution on Main Menu, and then load a saved game which retains a different aspect ratio option.
  • Basically when I load my saved game (which also retains options, it's designed to work this way), the saved file applies a different resolution, let's say a 16:9 one (i.e. 1920x1080), but then the fixed aspect ratio is not working as it should, but it keeps the value of when I changed it on Main Menu (i.e. 4:3).

My question is: can I refresh AC aspect ratio via script? So I can do that each time I call my SetOptions script (after loading a saved game)?
Thanks

P.S. I thought the aspect ratio was automatically applied each time the "Screen.SetResolution" is called, but my SetOptions do that, and yet it's not applied. So I wonder if there's a way to refresh that manually.

Comments

  • edited June 2023

    UPDATE:
    Apparently the problem is not with the Game Camera, which is correctly working also after loading, but with the various AC Menu UI (they are all Unity Prefabs).
    So the AC Menu UIs change properly the aspect ratio if I do from Main Menu Options or Pause Menu Options, but they have the issue above when changing from Main Menu Options and then Loading a saved option.
    Each of them has the Auto-correct UI Dimensions properly set. So maybe that's the script that needs to be refreshed? Or, in general, all the AC Menus?

    Or somehow trigger manually the Event "OnUpdatePlayableScreenArea"?

    I guess this last option might be the one that makes it work, but I'm not sure how to do it... any clues?

    Sorry for the confusion...

  • You can trigger the event manually with:

    KickStarter.eventManager.Call_OnUpdatePlayableScreenArea ();
    
  • edited June 2023

    Thanks, and what about the first part of my thread... I mean, calling a refresh of the aspect ratio of the Game Camera? Is there a way to call that too just to be sure? Or that is also refreshed with the event OnUpdatePlayableScreenArea?

    UPDATE: Apparently the OnUpdatePlayableScreenArea works only with the UI, but doesn't "refresh" the aspect ratio, so there's indeed a case in which my Game Camera set to 4:3 on Main Menu is kept even on a Loaded Game that retains options for a 16:9 resolution (which sets the UI correctly to 16:9, but doesn't affect the Game Camera). Maybe this has something to do with something in the persistent Persistent Engine? So at the moment I change my resolution in Main Menu (and the aspect ratio is adjusted), it keeps that value even after Loading a scene which set the saved options to a different ratio?

  • As this is a visual issue, I'm not totally clear on the problem you're describing without screenshots. However, the MainCamera's RecalculateRects function will update camera aspect ratio data:

    AC.KickStarter.mainCamera.RecalculateRects ();
    
  • Thank you Chris.
    After many attempts I've found out the issue was with another script I had that was adjusting the ratio... I removed it and AC alone is now handling it perfectly.

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.