Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Rendering.PostProcessing;
- public class ThermalController : MonoBehaviour
- {
- public Shader ThermalShader;
- float IntensityThermal;
- bool thermal;
- [SerializeField]
- PostProcessVolume postProcessVolume;
- Camera cam;
- // Start is called before the first frame update
- void Start()
- {
- cam = GetComponent<Camera>();
- cam.enabled = false;
- }
- // Update is called once per frame
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.T))
- {
- thermal = !thermal;
- SwitchThermal(thermal);
- }
- }
- void SwitchThermal(bool thermalB)
- {
- if (thermalB)
- {
- cam.enabled = true;
- IntensityThermal = 1;
- if(postProcessVolume != null)
- {
- postProcessVolume.weight = IntensityThermal;
- }
- cam.SetReplacementShader(ThermalShader, "ThermalVision");
- }
- else
- {
- cam.enabled = false;
- IntensityThermal = 0;
- if (postProcessVolume != null)
- {
- postProcessVolume.weight = IntensityThermal;
- }
- cam.ResetReplacementShader();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement