Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
0
Question by AnandAshar · Feb 28, 2018 at 07:58 AM · unity 5vuforiahue

Changing Hue using slider.

I was wondering how would I change the hue of my entire scene in real time using UI sliders. I want to use it on my ARCamera. Any help would be great. Thank you.

Comment
Add comment · Show 2
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
avatar image AnandAshar · Feb 28, 2018 at 09:39 AM 0
Share

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class shiftHue : $$anonymous$$onoBehaviour { float H=0;

 // Update is called once per frame
 void Update () {
 Color.HSVToRGB(H, 1,1);
     
 }
 public void adjustHue (float newHue){
     H=newHue;
 }

}

avatar image Helical · Mar 01, 2018 at 01:49 PM 1
Share

Not gonna formally answer, cause I'm to lazy, but it sounds like you want the Post Process stuff

https://docs.unity3d.com/$$anonymous$$anual/PostProcessingOverview.html

Another choice is to have a global hue variable for all shaders in the game, meaning your game needs to use custom written shaders and not the Unity prebuilt shaders.

https://docs.unity3d.com/ScriptReference/Shader.SetGlobalFloat.html

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by dishant27 · Feb 28, 2018 at 09:26 AM

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI; // Required when Using UI elements.
 
 public class Example : MonoBehaviour
 {
    public Slider mainSlider;
 public Light directionalLight;
 float H, S, V;

 public void Start()
 {
     Color.RGBToHSV(directionalLight.color, out H, out S, out V);
     //Adds a listener to the main slider and invokes a method when the value changes.
     mainSlider.onValueChanged.AddListener(delegate {ValueChangeCheck(); });
 }

 // Invoked when the value of the slider changes.
 public void ValueChangeCheck()
 {
     directionalLight.color = Color.HSVToRGB(mainSlider.value,S,V);      //removed new from here
     Debug.Log(mainSlider.value);
 }

}

// Also provide the reference to light and slider to the gameobject where you'll attach this script. ***Edited my answer including @Harinezumi's answer

Comment
Add comment · Show 2 · 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
avatar image Harinezumi · Feb 28, 2018 at 09:42 AM 1
Share

@dishant27 , is this what you wanted to do?

 float H, S, V;
 Color.RGBToHSV(directionLight.color, out H, out S, out V);
 directionalLight.color = Color.HSVToRGB(mainSlider.value, S, V);

Admittedly, google doesn't give you results with Color.RGBToHSV(), only the other way around.

avatar image dishant27 Harinezumi · Feb 28, 2018 at 09:45 AM 1
Share

yes, that would work. Thanks!

avatar image
0

Answer by AnandAshar · Mar 01, 2018 at 06:41 AM

Nothing happens when I run the code. I dropped the script to the ARCamera, then included the object in the slider and called the function. I' m not sure if I did it right. I'm new to unity and a step wise procedure would help me a lot. @Harinezumi @dishant27

Comment
Add comment · Show 5 · 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
avatar image dishant27 · Mar 01, 2018 at 09:21 AM 0
Share

1) Attach the above script to camera. (removed "new" keyword from line 21) 2) In inspector, drag and drop light source of your scene in the directionalLight field of script. 3) Then, drag and drop UI component slider in the mainSlider field of script. 4) Play & check the Hue value of the light Source in the editor by moving the handle of the slider.

avatar image AnandAshar dishant27 · Mar 01, 2018 at 10:32 AM 0
Share

@dishant27 I did that. But it doesnt change anything in the game mode. Although I can see the color of directional light being changed in the inspector..since I am using an ARCam (vuforia) nothing happens. Any help with that?

avatar image dishant27 AnandAshar · Mar 01, 2018 at 10:41 AM 0
Share

Because your RGB value of directional light color are near to 255. $$anonymous$$ake all them under 100, you'll find the significant variation with slider. Also keep a cube in screen to see how it's affecting the gameobjects.

Show more comments

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.

Follow this Question

Answers Answers and Comments

159 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

Related Questions

Error Building Android Player : Win32 Exception 0 Answers

How to connect microsoft translator api in unity ? 0 Answers

unity trackable lost 0 Answers

Is it possible for Vuforia to display the same scene when tracking different image trackers? 1 Answer

Detect small targets with Vuforia 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