Forum rules - please read before posting.

Quality Settings Menu

Feature Request

Would be great to have Quality Settings as an option in the AC menus, so players can adjust resolution, v sync, etc. As a non-programmer, this feature would be a very welcomed addition to AC.

I know that you can display the resolution dialog in the default Unity settings but this is less than ideal for a few reasons: 1) It's an extra start up step that isn't always needed. 2) It can't be translated. 3) It can't be easily modified to contain the options you want and to remove those you don't. 4) The pop-up window is ugly.

Comments

  • My feeling is that there's really no end to the number of options one could introduce here, so it's best left to custom option data to handle.  Even for non-programmers, it's quite a simple process and is walked through here.

    To adapt the tutorial to work with quality setting instead of screen resolution, you mainly just need to replace Screen.SetResolution with QualitySettings.SetQualityLevel.
  • Yeah, I guess there would be a lot of options to integrate. That makes sense. Thanks for the tutorial tip, I'll try that out!
  • Hello Chris and hello to all the adventure creators,
    I'm linking to this post because I'm trying to add the quality setting to the options menu.
    Reading here, I understand that I just need to change the "Screen.SetResolution" parameter to "QualitySettings.SetQualityLevel".
    But it's not clear to me how to do that.
    Following the tutorial on the Adventur Creator site, I was able to set the resolution setting, but if I wanted to add the quality setting as well, would I basically have to duplicate the "ActionApplyResolution" script, rename it and replace "Screen.SetResolution" with "QualitySettings.SetQualityLevel"?
    Sorry if this is a wrong question, but I just can't figure out what to do:
    Should I do the same initial procedure? Create a Global Variable, get the ID, put it in the script.
    Would it be possible to have both choices in the menu (resolution and quality)?
    If you can, would you be so kind to add a tutorial?
    Surely this is a simple operation, but as I have no programming knowledge, I get lost in trying to visualise how to do it.
    Thanks

  • The process for quality settings is largely the same: create a new variable, and use it to record the player's choice, and then use that to apply the correct setting.

    The difference with Quality Settings is that - at least so far as I'm aware - it's not possible to extract the various options through script. So rather than having a script auto-populate the Cycle element's labels, you'd have to manually set them in the Menu Manager.

    Another Action wouldn't be necessary - you could update both settings in the one:

    using UnityEngine;
    using AC;
    
    public class SetupOptionsMenu : MonoBehaviour
    {
    
        void Start ()
        {
            GenerateResolutionCycleOptions ();
            InitResolutionVariable ();
        }
    
        void GenerateResolutionCycleOptions ()
        {
            MenuCycle resolutionCycle = PlayerMenus.GetElementWithName ("Options", "ScreenResolution") as AC.MenuCycle;
    
            resolutionCycle.optionsArray.Clear ();
            foreach (Resolution resolution in Screen.resolutions)
            {
                string optionLabel = resolution.width.ToString () + " x " + resolution.height.ToString () + " (" + resolution.refreshRate.ToString () + ")";
                resolutionCycle.optionsArray.Add (optionLabel);
            }
        }
    
        void InitResolutionVariable ()
        {
            GVar variable = GlobalVariables.GetVariable (0); // Replace '0' with your resolution variable's ID number
            if (variable.IntegerValue == -1)
            {
                for (int i=0; i<Screen.resolutions.Length; i++)
                {
                    if (Screen.resolutions[i].width == Screen.currentResolution.width &&
                        Screen.resolutions[i].height == Screen.currentResolution.height &&
                        Screen.resolutions[i].refreshRate == Screen.currentResolution.refreshRate)
                    {
                        variable.IntegerValue = i;
                        return;
                    }
                }
                variable.IntegerValue = 0;
            }
        }
    
        void InitQualityVariable ()
        {
            GVar variable = GlobalVariables.GetVariable (1); // Replace '1' with your quality variable's ID number
            variable.IntegerValue = QualitySettings.GetQualityLevel ();
        }
    
    }
    

    And:

    using UnityEngine;
    using System.Collections.Generic;
    #if UNITY_EDITOR
    using UnityEditor;
    #endif
    
    namespace AC
    {
    
        [System.Serializable]
        public class ActionApplyResolution : Action
        {
    
            public ActionApplyResolution ()
            {
                this.isDisplayed = true;
                category = ActionCategory.Object;
                title = "Apply resolution";
            }
    
    
            override public float Run ()
            {
                int chosenResolutionIndex = GlobalVariables.GetIntegerValue (0); // Replace '0' with your resolution variable's ID number
                if (chosenResolutionIndex >= 0)
                {
                    Resolution chosenResolution = Screen.resolutions [chosenResolutionIndex];
    
                    Screen.SetResolution (chosenResolution.width, chosenResolution.height, Screen.fullScreen);
                    KickStarter.playerMenus.RecalculateAll ();
                }
    
                int qualityLevel = GlobalVariables.GetIntegerValue (1); // Replace '1' with your quality variable's ID number
                QualitySettings.SetQualityLevel (qualityLevel, true);
                return 0f;
            }
    
        }
    
    }
    
  • Thank you Chris for always being so available.
    As soon as I get in front of the computer I will try.

  • Everything works perfectly, I replaced the first script to the file "SetupOptionsMenu.cs", the second script to replace the file "ActionApplyResolution".
    I created a Global variable named quality, to which I gave Integer -1 connected to Option Data.
    In the two scripts I replaced the IDs with those of the two Global variables.
    In the Options Menu I duplicated the ScreenResolution element renaming it "quality", reassigned its Global Variable, and changed the number of choices to 3 (low, medium and high).
    Then in the Project settings of Unity under Quality, I left the 3 levels that interested me "Very Low", "Medium" and "ULtra", eliminating the others.
    Everything went smoothly, now after making the build, from the menu I have the possibility to set the graphic resolution and the level of detail.
    Thanks Chris

  • Just a word of advice for letting players feedle with your game settings, like Vsync for instance.
    I have recieved few complains that some graphics like sprites and GUI breaks down and randomly appear and disappear.

    Because those few have some super powerful stations and for no reason push thier computers to the limits playing little indie games. I mean it is not a heavy shooter where you need high frame rate, but they don't care and burn energy along with GPU.
    Of course it depends on how you built your game. But I forced frame rate to 60. and now it works fine on any station.

  • Hi SkyTree, thanks for the clarification.
    I thought about adding the graphics quality, because being my first experience with AC and Unity, in my little experience I probably don't know of any tricks that can streamline the amount of calculation.
    It's a 3D adventure, I've kept assets really low in polygons, but in the scenes, I've worked a lot with real time lighting, Partcle System and soft shadows.
    I think that this causes some jerks and lag on older computers that make the gaming experience difficult in some places.
    Now with the graphic levels selected low, I get a good increase of FPS because the details are reduced a lot, the shadows are canceled and the number of lights is decreased.
    I think this way the player can run the game even on low end computers or at least I hope so.

  • Hi guys (excuse my English),
    I have a question regarding the possibility to enable or disable a camera component and insert this feature in the options menu.
    In my case it is the Tool Aura2 that if I understand correctly is a component of the main camera used on AC.
    Since Aura 2 works on volumetric lights, its use is quite heavy, and I thought to insert in the game options the possibility to turn it off or on so that the player can decide whether to use it or not.
    So the procedure I think I'll have to follow will be similar to the one used to set game resolution and graphics quality.
    That is to have a script that refers to a global variable, take its ID and so be able to control the camera component (Aura2).
    Since I have no programming knowledge, is there anyone who could kindly pass me the lines of code to do this?
    If I have been unclear or you need more information please let me know.
    Even if there are alternative ways that are fine.
    Thank you for your attention.

  • As a simple on/off toggle, you'd want to rely on a Global Boolean variable, linked to Options Data, to control the state. You can use a Toggle element to control its value, and wouldn't need any extra script to update the display. If you're following the tutorial, you can do without the SetupOptionsMenu script for this.

    However, the custom Action's Run function would then instead be:

    override public float Run ()
    {
        bool isEnabled = GlobalVariables.GetBooleanValue (0); // Replace '0' with your own variable's ID number
        KickStarter.mainCamera.GetComponent <MyComponent>().enabled = isEnabled;
        return 0f;
    }
    

    You'll need to replace "MyComponent" with the name of the Aura component attached to your MainCamera, though.

  • Thanks Chris, in the end I decided to implement the lines of code you wrote, and I added them to the existing script you created for me some time ago.
    Now everything works, accessing a single script I can control resolution, quality and activate the component camera.
    I leave here below the modified script that could be useful.

    using UnityEngine;
    using System.Collections.Generic;
    using Aura2API;
    #if UNITY_EDITOR
    using UnityEditor;
    #endif
    
    namespace AC
    {
    
        [System.Serializable]
        public class ActionApplyResolution : Action
        {
    
            public ActionApplyResolution()
            {
                this.isDisplayed = true;
                category = ActionCategory.Object;
                title = "Apply resolution";
            }
    
    
            override public float Run()
            {
                int chosenResolutionIndex = GlobalVariables.GetIntegerValue(9); // Replace '0' with your resolution variable's ID number
                if (chosenResolutionIndex >= 0)
                {
                    Resolution chosenResolution = Screen.resolutions[chosenResolutionIndex];
    
                    Screen.SetResolution(chosenResolution.width, chosenResolution.height, Screen.fullScreen);
                    KickStarter.playerMenus.RecalculateAll();
                }
    
                int qualityLevel = GlobalVariables.GetIntegerValue(13); // Replace '1' with your quality variable's ID number
                QualitySettings.SetQualityLevel(qualityLevel, true);
    
                bool isEnabled = GlobalVariables.GetBooleanValue(15); // Replace '0' with your own variable's ID number
                KickStarter.mainCamera.GetComponent<AuraCamera>().enabled = isEnabled;
                return 0f;
    
            }
    
        }
    
    }
    
  • Hello everyone and wishing you a Happy New Year 2022.
    I'm linking to this post where Chris kindly wrote me the code to be able to turn a component off or on on the main camera.

    I use Unity version 2020.1.10f1 and Adventure Creator Version 1.74.5

    I try to explain what happens step by step so that it is quite clear what I am trying to achieve and what happens instead:

    On the unity store there is a tool called Aura 2 that gives the possibility to create and work on volumetric lights.
    This tool after being installed, gives the possibility to be activated on the light sources that we are interested in having the volumetric, and on the main camera that will display these lights giving them the desired effect.

    Now, I have created a Boolean Global variable connected to Option Data, and in the options menu, I have created a new Toggle element that refers to this variable.
    Then I added the script that Chris prepared for me to the existing script ActionApplyResolution.cs, so through that script, I have control of : Screen resolution, graphic quality and volumetric switch.

    Everything works perfectly, only I have the problem that when I change the scene, the camera comes back with the Aura2 component active, even if in the options it is selected as deactivated.
    The only way I found to solve the problem was to insert on the action lists OnLoad and OnStart of the scenes that are loaded to launch SetResolution again.
    In this way, I imagine the script checks the global Boolean variable linked to the volumetric, and depending on how it is set, resets the Aura2 component of the camera on or off.

    But maybe there is a better way that I don't know?
    Or is it enough to add a few lines of code to the SetupOptionMenu.cs file that is read every time the game loads?
    I apologise if I've written some heresies and I thank in advance anyone who has the will to answer this probably trivial question.

    ActionApplyResolution.cs

    using UnityEngine;
    using System.Collections.Generic;
    using Aura2API;
    #if UNITY_EDITOR
    using UnityEditor;
    #endif
    
    namespace AC
    {
    
        [System.Serializable]
        public class ActionApplyResolution : Action
        {
    
            public ActionApplyResolution()
            {
                this.isDisplayed = true;
                category = ActionCategory.Object;
                title = "Apply resolution";
            }
    
    
            override public float Run()
            {
                int chosenResolutionIndex = GlobalVariables.GetIntegerValue(9); // Replace '0' with your resolution variable's ID number
                if (chosenResolutionIndex >= 0)
                {
                    Resolution chosenResolution = Screen.resolutions[chosenResolutionIndex];
    
                    Screen.SetResolution(chosenResolution.width, chosenResolution.height, Screen.fullScreen);
                    KickStarter.playerMenus.RecalculateAll();
                }
    
                int qualityLevel = GlobalVariables.GetIntegerValue(13); // Replace '1' with your quality variable's ID number
                QualitySettings.SetQualityLevel(qualityLevel, true);
    
                bool isEnabled = GlobalVariables.GetBooleanValue(19); // Replace '0' with your own variable's ID number
                KickStarter.mainCamera.GetComponent<AuraCamera>().enabled = isEnabled;
                return 0f;
    
            }
    
        }
    
    }
    

    SetupOptionMenu.cs

    using UnityEngine;
    using AC;
    
    public class SetupOptionsMenu : MonoBehaviour
    {
    
        void Start()
        {
            GenerateResolutionCycleOptions();
            InitResolutionVariable();
        }
    
        void GenerateResolutionCycleOptions()
        {
            MenuCycle resolutionCycle = PlayerMenus.GetElementWithName("Options", "ScreenResolution") as AC.MenuCycle;
    
            resolutionCycle.optionsArray.Clear();
            foreach (Resolution resolution in Screen.resolutions)
            {
                string optionLabel = resolution.width.ToString() + " x " + resolution.height.ToString() + " (" + resolution.refreshRate.ToString() + ")";
                resolutionCycle.optionsArray.Add(optionLabel);
            }
        }
    
        void InitResolutionVariable()
        {
            GVar variable = GlobalVariables.GetVariable(9); // Replace '0' with your resolution variable's ID number
            if (variable.IntegerValue == -1)
            {
                for (int i = 0; i < Screen.resolutions.Length; i++)
                {
                    if (Screen.resolutions[i].width == Screen.currentResolution.width &&
                        Screen.resolutions[i].height == Screen.currentResolution.height &&
                        Screen.resolutions[i].refreshRate == Screen.currentResolution.refreshRate)
                    {
                        variable.IntegerValue = i;
                        return;
                    }
                }
                variable.IntegerValue = 0;
            }
        }
    
        void InitQualityVariable()
        {
            GVar variable = GlobalVariables.GetVariable(13); // Replace '1' with your quality variable's ID number
            variable.IntegerValue = QualitySettings.GetQualityLevel();
        }
    
    }
    
  • If you're dealing with a new MainCamera object in each scene, you will have to update it after the scene switch.

    This can be automated, however. If you create an ActionList asset with the above Action, you can trigger it after a scene change with the following script:

    using UnityEngine;
    using AC;
    
    public class RunAssetOnSceneChange : MonoBehaviour
    {
    
        public ActionListAsset actionListAsset;
    
        private void OnEnable () { EventManager.OnAfterChangeScene += OnAfterChangeScene; }
        private void OnDisable () { EventManager.OnAfterChangeScene -= OnAfterChangeScene; }
    
        private void OnAfterChangeScene (LoadingGame loadingGame)
        {
            actionListAsset.Interact ();
        }
    
    }
    
  • Hi Chris, thanks for your reply, the code you mentioned above I think is what I was asking for; an action list to run at the start of a new scene, go to restore the camera components as they were set during the choice in the options menu.

    Only I think I'm doing something wrong, because I can't insert the script in the Action Manager, this is my procedure:

    1- I duplicate the ActionTemplate.cs file contained in Assets/AdventureCreator/Scripts/ActionList
    2- Then I rename the copy to RunAssetOnSceneChange, and paste in the script you passed me above.
    3- I move the file to a new folder.
    4- I go to the Action Manager menu, click on the folder icon to give the path where I moved the RunAssetOnSceneChange.cs file.
    5- But I get an error saying so:

    The script 'F:\UnityProject\Terisa\Assets\Script2\RunAssetOnSceneChange.cs' must derive from AC's Action class in order to be available as an Action.

    -> AC debug logger
    UnityEngine.Debug:LogError(Object, Object)
    AC.ACDebug:LogError(Object, Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:46)
    AC.AdventureCreator:AddActionsFromFolder(ActionsManager, String, List`1) (at Assets/AdventureCreator/Scripts/Managers/Editor/AdventureCreator.cs:590)
    AC.AdventureCreator:RefreshActions() (at Assets/AdventureCreator/Scripts/Managers/Editor/AdventureCreator.cs:517)
    AC.AdventureCreator:OnGUI() (at Assets/AdventureCreator/Scripts/Managers/Editor/AdventureCreator.cs:343)
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

    Can you kindly tell me where I am going wrong?
    Thank you for your patience.

  • My code above was not a new Action - rather a script to call an ActionList that has the correct Action (Object: Apply resolution) in your project.

    Remove the above script's folder from the Actions Manager, and instead attach it as a component to a persistent object in your game - i.e. the Player prefab, AC's PersistentEngine prefab, or a custom EventSystem prefab.

  • Thanks for the help, I'll try now.

  • It works!
    As always thank you, your availability is much appreciated.

    I make a small point to see if I understand what you made me do:
    I attached the code you passed me "RunAssetOnSceneChange" to AC's prefab persistent engine.
    Since the engine is loaded at each scene change, this code runs, and being attached to the setresolution Action list, it restores the camera components by going to see its Boolean Global Variable inherent to the component concerned (in this case, check if it is false and then deactivates the Aura2 component, starting the scene with the deactivated component).

    It's correct?

    Thanks Chris.

  • Sounds right to me!

  • Everything works 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.