Quantcast
Channel: Questions in topic: "post processing"
Viewing all articles
Browse latest Browse all 713

Why am I getting error when using postprocessing v2 on profile.TryGetSettings ?

$
0
0
In the editor on my Camera I added two components : Post Process Layer and Post Process Volume On the first component the layer I changed the Layer to a layer I added PostProcessing On the second component I set the Is Global to true and added one effect for now Depth Of Field Now I want to change and set values to the Depth Of Field Focal Length via a script. So I created a new script : using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Rendering.PostProcessing; public class PostprocessingEffects : MonoBehaviour { private PostProcessVolume postProcessVolume; private PostprocessingEffects depthOfField; void Start() { postProcessVolume = GetComponent(); postProcessVolume.profile.TryGetSettings(out depthOfField); } // Update is called once per frame void Update() { } /*public GameObject player; public bool dephOfFieldFinished = false; private PostProcessVolume postProcessVolume; private DepthOfField depthOffield; private Animator playerAnimator; private float clipLength; private Coroutine depthOfFieldRoutineRef; // Start is called before the first frame update void Start() { postProcessVolume = GetComponent(); } private void OnEnable() { if (depthOfFieldRoutineRef != null) { StopCoroutine(depthOfFieldRoutineRef); } playerAnimator = player.GetComponent(); clipLength = playerAnimator.GetCurrentAnimatorStateInfo(0).length; var depthOfField = postProcessingProfile.depthOfField.settings; depthOfField.focalLength = 300; StartCoroutine(changeValueOverTime(depthOfField.focalLength, 1, clipLength)); postProcessingProfile.depthOfField.settings = depthOfField; // Don't forget to set depthOfFieldRoutineRef to null again at the end of routine! } IEnumerator changeValueOverTime(float fromVal, float toVal, float duration) { //playerLockManager.PlayerLockState(true, true); float counter = 0f; while (counter < duration) { var dof = postProcessingProfile.depthOfField.settings; if (Time.timeScale == 0) counter += Time.unscaledDeltaTime; else counter += Time.deltaTime; float val = Mathf.Lerp(fromVal, toVal, counter / duration); dof.focalLength = val; postProcessingProfile.depthOfField.settings = dof; yield return null; } playerAnimator.enabled = false; dephOfFieldFinished = true; depthOfFieldRoutineRef = null; }*/ } The bottom code is my old script when using postprocessing v1 now I want to do the same with my old code but with postprocessing v2 I'm getting error on the line : postProcessVolume.profile.TryGetSettings(out depthOfField); On the TryGetSettings and the error is : The type 'PostprocessingEffects' cannot be used as type parameter 'T' in the generic type or method 'PostProcessProfile.TryGetSettings(out T)'. There is no implicit reference conversion from 'PostprocessingEffects' to 'UnityEngine.Rendering.PostProcessing.PostProcessEffectSettings'. How can I fix this error and how can I use it with my old code ?

Viewing all articles
Browse latest Browse all 713

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>