Hello community, hope everyone is having a nice warm day
![:) :)](https://adventurecreator.org/forum/resources/emoji/smile.png)
.
is it possible to make a built in brightness option using adventure creator menu system? just like the "speech and music" slider elements in the option menu that automatically save when adjusted?
Comments
Further options are certainly possible, though as there's no end to what users would need AC takes the approach of allowing users to add their own with simple scripting. A tutorial on creating a "screen resolution" option can be found here.
It seems to work but it doesn't work! When I move the slider to the end, it only switch to white (rgbValue), but not the other way round (black color). What I want is a gradual increase and decrease(from black to white and reverse) . Hm, I missing something... by the way, thank's Chris
If you want the Action to run over time, you'll have to set the Action's "isRunning" bool to True, and return "defaultPauseTime" instead of zero. This will cause the Action to re-run the next frame, and will only cease once you set "isRunning" back to False and return zero. See the original ActionTemplate file for more. Once you have the Action running over multiple frames, you can change the brightness gradually instead of instantly.
Alternatively, you can move this all to a separate script and rely on a regular "Update" function. The Action just needs to be able to pass the intended brightness to it, which can be done without running over time.
Hell guys,
After some research I found a really nice way to create a Brightness/gamma menu. Here's what I did and then the questions to link it to AC.
First: we are using URP. We didn't download the Post Processing Package. We didn't mess around with any camera.
After we put all the lights, I've created an empty object and added the "Volume" script (I think it comes with URP).
Then I added the following options (after creating a profile):
Then the script: The script is easy enough. I will post here just the part I did: the post exposure. Basically each option should be one other float/int and one more "linking" in the update().
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class BrightnessOptions : MonoBehaviour
{
public Volume volume;
public ColorAdjustments CA;
[Range(-2, 2)] public VolumeParameter postExposureOut = new VolumeParameter();
[Range(-2, 2)] public float postExposureValue = 0;
}
Now the questions:
1) I would like to cycle it like a Music/SFX/Speech. I found that after creating the variable (which originally was a "float", It couldn't find the variable because it wasn't an int. Any way to do it with floats?
2) The script works at runtime but I'm finding it hard to link it through the Action List. I mean, each number of the int should be the Global Variable value. This is var17, it's Global, int (want to be float actually).
I'm finding it hard to do that linking between numbers.
Any help on the above will be great. Yes, I've read the screen resolution tutorial but I think that one is even harder than this.
Thanks a lot! I think many people will make use of this, so when I'm finished I will post here the final script but so far, we are on the right track!
AC 1.75.4
Unity 2020.3.27f1
Universal Renderer Pipeline needed!
For question 1)![:) :)](https://adventurecreator.org/forum/resources/emoji/smile.png)
I just found "Cycle" is not the actual option I should use, rather "Slider". Now I can use floats
Now the question regarding this is: any chance negative values are also taken in consideration when "filling" the bars? As of now, I can only move forward even though I set it at -20 and +20. Maybe go 0 to right and 0 to left. Because as far as I can see it now, it starts at -20 and then goes all the way to 20.
And for the second part regarding question 1): the number of steps for the following scenario, what does it mean for floats?
Thanks a lot!
You'll need to rely on an AC Global Variable so that you can sync its value with Options Data - see the Manual's "Options data" chapter for details.
Variables can be read through script - see the Manual's "Variable scripting" chapter for details. If the variable was named "Brightness", your script could be adapted to something like:
Slider elements of the type "Float Variable" can be given minimum and maximum values in the Menu Manager. Alternatively, you can keep its range (and that of the AC variable) to 0 -> 1, and convert it before applying to postExposureOut:
I made it work. Let me explain what I did, and then the questions:
I made a custom "Options" menu with a button which will bring me to the video part where I have labels, sliders and buttons. The Labels are the Gamma, etc etc etc. The Sliders are the, well, sliders. Each one has a minimum value and a maximum which should be replicated in the script (below) and the AC menus. So all three have to have the same min and max. Then the button is just an action list which will give me the default button (0 in all cases). I didn't need to do anything crazy and works.
Also, this same menu has a prefab which has to be consistent in all scenes and basically tweaks the values. This is the prefab which has this script and is in the Menu and the scene. Any change on the scene (options menu or video options menu) will affect the prefab hence the scene. If you don't have the prefab of the video in the scene, when the menu turns off, the changes are discarded. Simply prefabing this object with the script and the "Volume" script is enough. Pictures below.
1) But, Chris, I found a problem: the buttons activate a simple action list which just sets the Variable to Zero, but everytime I click, I can see the player behind the menu moving one frame. Every click is one click moving. I noticed that even when transitioning between Pause and Options (Options is inside Pause), it also moves the player one frame inbetween. I can't make it "freeze" even though the Pause menu has the "pause gameplay".
In the screenshot I'm showing below, you can check how the character slowly moves everytime I press on a button. All "default buttons" do the same for different variables. If I go back to the menu, again moves a bit.
2) For some reason this only works on gameplay lights, not menus. I may have to research harder because UI elements just like our inventory (wallet) and the menus are not affected![:/ :/](https://adventurecreator.org/forum/resources/emoji/confused.png)
https://imgur.com/a/P7ynwvh
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using AC;
public class BrightnessOptions : MonoBehaviour
{
public Volume volume;
public ColorAdjustments CA;
public WhiteBalance BA;
public LiftGammaGain LGG;
}
Uncheck Unfreezes 'Pause' menus? in the properties of your ActionLists.
This isn't AC-related, but a Canvas's Render Mode needs to be set to Screen Space Camera for it to react to post-processing.
I can't believe I've never saw this ever!. Man thanks!!!
https://imgur.com/a/7IG6ktD
As for question 2, yes I knew it wasn't AC related in advance, but your words were the trigger I needed to at least look in the right direction. I also knew from following the forum the brightness is not AC related, yet someone can now find a good working method and everything they could need to make it work. Thank you both for helping me add a nice feature to the game.
Have a good day!
I'm sorry to reopen this old topic, but I am trying to implement the Brightness option into AC Options Menu, and none of the above works for me.
I am trying to follow the AC Tutorial "Adding a Screen Res Option" combined with this YT Tutorial, the individual steps work but overall I am not having success.
From the YT tutorial:
* I am using the Post Processing package.
* Added Post process layer to Main Camera, selected it as the Trigger, and created and selected a Postprocessing layer.
* Created empty object Brightness in Postprocessing layer and added Post Processing Volume to it (effect: Global) and created a new Profile where I selected Auto Exposure.
* I skipped the part where it is made to affect UI as well, for simplicity.
* Created the Script and added it to the Brightness object.
The Script gives some public variables to the Brightness object, I managed to add only the Brightness and the Layer, but failed to add the Slider, as I have no idea how to get to its object. I think this might the first issue.
Didn’t follow the tutorial further after this part.
From the AC Tutorial
I have the Brightness Variable (ID: 0). I have my slider in the Options ACMenu ready.
I skipped the generation of choices (irrelevant for brightness) and the function that sets the correct value of our ScreenResolution integer variable, if it's found to be -1 (so didn't create the SetupOptionsMenu.cs script).
I then created my own Action from the ActionTemplate.cs, but I am a coding noob, so I assume this is completely wrong:
In the end I created the action using custom action script (Engine: Brightness) that I added to the Slider element in my Options menu (see the image above).
In the Editor, the exposure changes nicely when I move slider within the Post Procees Volume component in the Brightness object. And when I move my Brightness slider in the AC Options menu, the global Brightness variable responds accordingly.
But overall, it is not working, and I am lost.
I assume something should be done with the public variable in the script from the YT tutorial while the Custom Action Script is lacking some code.
Please help.
The brightnessSlider variable in your script is not referenced in the rest of the code - assigning it will make no difference.
There's also no need for a custom Action - an updated tutorial that simplifies the coding process can be found here.
Firstly, go to your BrigtnessSlider element and set its Slider affects to Float Variable. Have it link to a Float variable named e.g. Brightness, and make sure that the variable's Link to property is set to Options Data.
Next, use this for your Brighness script:
Make this a prefab, attach a Constant ID component, and then check Retain in prefab?, so that its ID is the same each time you place the prefab in a scene.
It should then just be a case of calling this script's
AdjustBrightness
function at the following times:Each time, run an Object: Send message Action that sends the custom message AdjustBrightness to the Brightness object in the scene. The unique ConstantID number should be recorded and displayed, so that it gets found again when re-opening a scene.
Thank you, it works!
I just have one more question. I would like the brightness to influence UI as well. Specifically, I have a Unity UI prefab-based "menu" whose only purpose is to act as a background to the main menu. it is called MainBackground.
I followed the YT video and created a duplicate for the NavCam called NavCamUI. I added the post-processing Layer, set depth to 1, and culling mask for UI only (for the original NavCam, I selected everything but UI). I removed of all components except Camera (the basic unity one), Constant ID, and the Postprocessing Layer.
I moved my MainBackground prefab back to the scene, opened its canvas, set Render Mode - Screen Space Camera, selected the new NavCamUI, and deleted the prefab from the scene again.
But when I run the game, this menu does not appear at all.
What am I doing wrong?
The prefab's Canvas component will lose the reference to the scene-based NavCamUI object once you remove it from the scene.
One way around this is to attach a script to the Canvas to assign the NavCamUI at runtime. Something like:
I added it into the canvas of the menu, but it still does not appear.
This is how the inspector of the Canvas looks like: