「毎日Unity」の技術ブログ

開発で役立つ情報を発信する

【UnityC#】スクリプトからVolumeを変更する方法

スクリプトからVolumeを変更する方法をメモ。

[ 変更方法 ]

VolumeにあるBloomのIntensityを10.0fに変更するスクリプトです。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;

public class EnvironmentManager : MonoBehaviour
{
    private Volume volume;
    private Bloom bloom;

    private void Start()
    {
        volume = GameObject.Find("Post-process Volume").GetComponent<Volume>();
        volume.profile.TryGet(out bloom);

        bloom.intensity.value = 10.0f;
    }
}