Setting Lift-Gamma-Gain values from C# script? (URP, Post-Processing v2)
So I want to change values of a "Lift Gamma Gain" element located in a volume profile asset. There is a major problem though. I have been unable to find code reference for doing that and I am uncertain whether the change from code is even possible. The value I'm mostly intereseted in is gain. Is there any way to change that from my script? Thanks beforehands :)
Answer by Jamez0r · May 27, 2021 at 06:35 PM
This shows how to change the "alpha" portion of the Gamma (the slider at the bottom of the gamma section when you look at it in the inspector). You should be able to figure out the rest from it - the color-wheel colors are just the x/y/z parts of the Vector4.
public class LiftGammaGainController : MonoBehaviour {
public static LiftGammaGainController instance;
[HideInInspector] public Volume renderingVolume;
LiftGammaGain liftGammaGain;
private void Awake() {
instance = this;
renderingVolume = GetComponent<Volume>();
if (!renderingVolume.profile.TryGet(out liftGammaGain)) throw new System.NullReferenceException(nameof(liftGammaGain));
}
public void SetGammaAlpha(float gammaAlpha) {
liftGammaGain.gamma.Override(new Vector4(1f, 1f, 1f, gammaAlpha));
}
public float GetGammaAlpha() { return liftGammaGain.gamma.value.w; }
}
Your answer
Follow this Question
Related Questions
Creating Windows Universal Plugin for Unity 1 Answer
SignInWith Apple Capability is not available in Unity3d 2017 LTS version 0 Answers
Changing material type in a URP Lit material does not take effect until material is viewed in editor 0 Answers