Controlling the intensity of bloom through the input field,Controlling the intensity of bloom through a input field for an AR application

I’m trying to control the intensity of bloom through an input field, but when I enter the value in the input field on my mobile, the intensity doesn’t change.
I can’t figure out what the problem is, can someone help me.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.IO;
using System.Linq;
using TMPro;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.Rendering.PostProcessing;

public class BloomEffectController : MonoBehaviour
{
    public PostProcessVolume postProcessVolume;
    public Bloom bloom;
    public TMP_InputField inputField;


    private void Start()
    {
        inputField = GetComponent<TMP_InputField>();
        postProcessVolume = GetComponent<PostProcessVolume>();
        postProcessVolume.profile.TryGetSettings(out bloom);

        
        inputField.onValueChanged.AddListener(SetBloomIntensity);
        
    }

    public void SetBloomIntensity(string value)
    {
        
        if (float.TryParse(value, out float intensity))
        {
            bloom.enabled.value = true;
            bloom.intensity.value = intensity;
           
        }
    }
}

@unity_2020ec_fidafareesha_a - First of all, make sure you’ve correctly referenced the PostProcessVolume and TMP_InputField. From your code, it seems like you’re trying to get these components from the same game object the script is attached to. If they are on different objects, the GetComponent call will return null and you will not be able to manipulate the bloom or input field. Do you have any errors in your console?

In your case, since you’ve already declared public variables for these components, you can assign them directly from the inspector. Alternatively, if the components are indeed on the same object, you can leave it as is.

First, check if the input field is detecting changes: In your SetBloomIntensity function, add a debug line to print the received value.

public void SetBloomIntensity(string value)
{
    Debug.Log("Received value: " + value);
    // rest of your code
}

If the value is not being printed, the issue is with the input field triggering the event.

If the value is printed, but the bloom intensity doesn’t change, then the problem could be with accessing or setting the bloom settings. Add a Debug.Log after setting the intensity to verify.

public void SetBloomIntensity(string value)
{
    // your code
    if (float.TryParse(value, out float intensity))
    {
        bloom.enabled.value = true;
        bloom.intensity.value = intensity;
        Debug.Log("Set intensity: " + bloom.intensity.value);
    }
}

If the intensity value is not printed, or it doesn’t change, the issue might be with accessing the bloom settings.

First try these things and then post if it doesn’t fix it and we can try look deeper.