ステージの拡張2(暗視モードの作成)








ポストプロセスを管理する
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
public class PPManager : MonoBehaviour
{
public PostProcessProfile baseFile;
public PostProcessProfile nightVisionFile;
private PostProcessVolume processVolume;
void Start()
{
processVolume = GetComponent<PostProcessVolume>();
processVolume.profile = baseFile;
}
// ポストプロセスファイルを外部から変更するメソッド
// 暗視モードに変更
public void ChangeNightVision()
{
processVolume.profile = nightVisionFile;
}
// ベースモードに変更
public void ChangeBase()
{
processVolume.profile = baseFile;
}
}


ポストプロセスのプロファイルを外部から変更する
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Sensor2 : SensorBase
{
// ★コード追加(暗視モード)
public GameObject ppManager;
public override void OnTriggerEnter(Collider other)
{
base.OnTriggerEnter(other);
if(other.CompareTag("Player"))
{
AudioSource.PlayClipAtPoint(sound, Camera.main.transform.position);
target.GetComponent<DoorMove>().enabled = true;
// ★コード追加(暗視モード)
ppManager.GetComponent<PPManager>().ChangeNightVision();
}
}
}



【2021版】X_Mission(全34回)
他のコースを見る







ポストプロセスを管理する
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
public class PPManager : MonoBehaviour
{
public PostProcessProfile baseFile;
public PostProcessProfile nightVisionFile;
private PostProcessVolume processVolume;
void Start()
{
processVolume = GetComponent<PostProcessVolume>();
processVolume.profile = baseFile;
}
// ポストプロセスファイルを外部から変更するメソッド
// 暗視モードに変更
public void ChangeNightVision()
{
processVolume.profile = nightVisionFile;
}
// ベースモードに変更
public void ChangeBase()
{
processVolume.profile = baseFile;
}
}


ポストプロセスのプロファイルを外部から変更する
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Sensor2 : SensorBase
{
// ★コード追加(暗視モード)
public GameObject ppManager;
public override void OnTriggerEnter(Collider other)
{
base.OnTriggerEnter(other);
if(other.CompareTag("Player"))
{
AudioSource.PlayClipAtPoint(sound, Camera.main.transform.position);
target.GetComponent<DoorMove>().enabled = true;
// ★コード追加(暗視モード)
ppManager.GetComponent<PPManager>().ChangeNightVision();
}
}
}



ステージの拡張2(暗視モードの作成)