Forum rules - please read before posting.

Conflict between a script and "Pause game when enabled" option menu

Hi everyone,
AC 1.69.0 + Unity 2019.2.17f1 on a 2d game.

In these days we improve a windowed system within the game: so we have the options menu and, inside it a toggle element (windowed) type on custom script that allows to switch from windowed to full screen. The options menu has an ActionList when turn on and off (the EnterSubMenu and ExitSubMenu from title tutorial where I checked if I am in title screen scene and lock/unlock a menu). It's all ok when "Pause game when enable" is unchecked (I open the game, the option menu, any other menus and works correctly), but, when I check it and build, when I press on Options menu (with option full screen active) it changes in windowed and the toggle is not correct, like if there is something in press Option menu button that call something in windowed element, but only when "Pause game when enable" is checked. The issue is only for Options menu, also the other menus (Load, Save, etc) has the "Pause game when enable" checked, but they work perfectly.

These are the scripts for windowed mode:

ActionSwitchScreeMode:

using UnityEngine;
using System.Collections;

namespace AC
{

[System.Serializable]
public class ActionSwitchScreenMode : Action
{
    public ActionSwitchScreenMode()
    {
        this.isDisplayed = true;
        category = ActionCategory.Engine;
        title = "Switch Screen Mode";
    }


    override public float Run ()
    {
        bool bSwitch = !Screen.fullScreen;

        Screen.SetResolution(Screen.width, Screen.height, bSwitch);

        MenuToggle windowedToggle = PlayerMenus.GetElementWithName("OptionsNew", "Windowed") as MenuToggle;

        if (windowedToggle != null)
            windowedToggle.isOn = !bSwitch;

        KickStarter.playerMenus.RecalculateAll();

        return 0f;
    }       
}

}

and ActionScreenModeLabel:

using UnityEngine;
using System.Collections;

namespace AC
{

[System.Serializable]
public class ActionScreenModeLabel : Action
{
    public ActionScreenModeLabel()
    {
        this.isDisplayed = true;
        category = ActionCategory.Engine;
        title = "Set Screen Mode Label";
    }


    override public float Run()
    {
        MenuToggle windowedToggle = PlayerMenus.GetElementWithName("OptionsNew", "Windowed") as MenuToggle;

        if (windowedToggle != null)
            windowedToggle.isOn = !Screen.fullScreen;

        KickStarter.playerMenus.RecalculateAll();

        return 0f;
    }
}

}

I can't understand where is the issue.

Thank you.

Comments

  • I'm not clear on the issue - are the Actions above being run incorrectly, causing the game to go into windowed mode when it shouldn't do?

    The recommended way of handling graphical options is to store them as Options-linked Global Variables - so that their values persist between save games and game restarts. Instead of checking/setting the value of your Toggle element through code, try just linking it to an Options-linked Boolean variable - and then read the Variable's value, instead of the Toggle element, when changing screen mode.

  • With the actions above the game works correctly (so I can change from windowed to full screen in correct way), but, when I check the "Pause game when enable" option in Options Menu, when I click on Options, if, it set on full screen, it changes it on windowed mode without to update the toggle mode (so I have a windowed mode with the full screen toggle active).

  • Only the first Action would affect the full-screen mode. When is this run?

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.