0

我正在使用后期处理工具来更改场景的颜色(我的场景包括一个 AR 相机,这是唯一的主要组件)。

我的目标是使用滑块改变场景的色调。该工具允许我在构建它时执行此操作,但我想确保我允许用户根据他们的选择更改色调(尝试构建色盲校正应用程序)。

例如,如果一个人患有 Deuteranopia,假设色相偏移 -35 部分允许他们看到在其他具有相同色盲类型的人的情况下不会看到的颜色,则色相可能会延迟。

所以,我希望你能帮助我创建一个后处理实用程序包控制器,让我可以使用 UI 滑块控制色相变化。

谢谢你。

正如你在这里看到的我的检查员,我想在我的画布上拥有相同的滑块控件:

正如您在这里看到的我的检查员,我想在我的画布上拥有相同的滑块控件,仅色相偏移

4

1 回答 1

-1

你怎么能这样做?

  1. 制作一个滑块:图片
  2. 将最小值和最大值分别设置为 -255、255:图片
  3. 添加一个名为“HueFromSlider”的新脚本:图片
  4. 将此代码添加到脚本中:


    using UnityEngine;
    using UnityEngine.PostProcessing;
    using UnityEngine.UI;

    public class HueFromSlider : MonoBehaviour 
    {
        public PostProcessingProfile profile; // A reference to the profile
        ColorGradingModel model; // The color grading model
        ColorGradingModel.Settings settings; // The color grading model settings.

        public Slider slider; // A reference to the slider so that on start it goes back to were it was.

        private void Start()
        {
            model = profile.colorGrading; // Set the model
            settings = model.settings; // Set the settings
            if (slider != null) // Set the slider back to what it was only if it has been referenced.
                slider.value = settings.basic.hueShift;
        }

        public void ChangeHue(float hue)
        {
            settings.basic.hueShift = hue; // Set the hue in the settings
            model.settings = settings; // Set the settings of the model
            profile.colorGrading = model; // set the profile model to the model
        }
    }

  1. 如果您没有后处理配置文件,请创建一个新的后处理配置文件:转到项目,右键单击并选择创建>后处理配置文件。
  2. 在检查器中,将配置文件拖动到脚本和滑块(可选)。
  3. 在滑块中,将“On Value Changed”回调添加到“脚本”>ChangeHue。确保将其选择为动态浮动。它应该如下所示:图片
  4. 完毕。


或者我的预制包: https ://drive.google.com/open?id=1coTuy2M5Jlrpvm-vOu3F3B_liddrA19t

于 2018-03-01T20:17:57.430 回答