Forum rules - please read before posting.

GraphicOptions.cs - limiting resolutions to specified aspect ratios

AC v1.75.3, Unity 2019.4.26f1

Hey, coming to the end of another project with AC!

I'm currently working with a friend (who is much better at scripting than I am!) to modify the provided GraphicOption script that comes with the adventure creator graphic options template.

We're trying to filter the resolutions by aspect ratio, in this case 16:9, 16:10 and 21:9.

I appreciate this is more of a general scripting question than one specific to AC but I thought it was worth posting here for anyone who might be looking for a similar solution in the future.

Our current code can be found here: https://pastebin.com/R4e3vZsc

Unfortunately I'm getting a null reference exception on line 278 (applying our supported resolutions array).

We added a resolution filter to the UpdateUIValues() function but suspect Apply() may be getting called before this list has populated.

I was hoping someone here might have had experience with modifying this script or tackled a similar problem.

Thanks in advance!

Comments

  • Just to add some extra context, GraphicOptions.Apply is being called by the ApplyGraphicOptions actionlist asset that I have set to run on start game. The null reference exception on line 278 occurs whenever Apply or SaveAndApply is called.

    Here is a comparison of the original GraphicOptions script provided on the AC downloads page and our modified one:

    https://www.diffchecker.com/55PD57UF/

  • After a lot of trial and error, I believe we've fixed it!

    https://pastebin.com/bGyPZbZi

  • Looks good! I'll see if this can be adapted back into the template as an optional feature.

  • That's great, I'm sure it would be helpful to others.

    Might be worth noting I'm currently looking at further filtering the list to remove options below a certain vertical resolution. Currently on some devices you are able to set the resolution so low that menus/text become illegible. When testing on Steam Deck for example, you can select 320x200 (an unfortunately blurry mess in a game designed for HD resolutions).

    It's a shame Unity don't have more out of the box features for these things.

  • Yes, that should be possible too - I'll look into that.

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.