您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
41 行
1.1 KiB
41 行
1.1 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.XR.ARFoundation;
|
|
|
|
public class CameraGrain: MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
ARCameraManager m_CameraManager;
|
|
public ARCameraManager cameraManager
|
|
{
|
|
get { return m_CameraManager; }
|
|
set { m_CameraManager = value; }
|
|
}
|
|
|
|
Renderer m_Renderer;
|
|
|
|
void Start()
|
|
{
|
|
if(m_CameraManager == null)
|
|
{
|
|
m_CameraManager = FindObjectOfType (typeof(ARCameraManager)) as ARCameraManager;
|
|
}
|
|
|
|
m_Renderer = GetComponent<Renderer>();
|
|
m_CameraManager.frameReceived += OnReceivedFrame;
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
m_CameraManager.frameReceived -= OnReceivedFrame;
|
|
}
|
|
|
|
void OnReceivedFrame(ARCameraFrameEventArgs eventArgs){
|
|
if(m_Renderer != null && eventArgs.cameraGrainTexture != null)
|
|
{
|
|
m_Renderer.material.SetTexture("_NoiseTex", eventArgs.cameraGrainTexture);
|
|
m_Renderer.material.SetFloat("_NoiseIntensity", eventArgs.noiseIntensity);
|
|
}
|
|
}
|
|
}
|