• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by unity_2020ec_fidafareesha_a · 4 days ago · unityeditorbloompostprocess

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;
            
         }
     }
 }
Comment

People who like this

0 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by SteenPetersen · 4 days ago

@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.

Comment
nihirum

People who like this

1 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Update about the future of Unity Answers

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta later in June. Please note, we are aiming to set Unity Answers to read-only mode on the 31st of May in order to prepare for the final data migration.

For more information, please read our full announcement.

Follow this Question

Answers Answers and Comments

160 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Not able to add iCloud to XCode project via PostProcessing script using the XCodeAPI 1 Answer

What`s the link of Offline installer of Unity 2017 3.0?? 0 Answers

Having trouble with Position X location on objects 0 Answers

can't see monodevelop in External script editor 0 Answers

update the transform scale in run time 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges