Shan Jiang
4 年前
当前提交
73f0e833
共有 9 个文件被更改,包括 126 次插入 和 51 次删除
-
2Assets/Scenes/LightEstimation/HDRLightEstimation.unity
-
7Assets/Scripts/BasicLightEstimationUI.cs
-
20Assets/Scripts/HDRLightEstimationUI.cs
-
39Assets/Scripts/HDRLightEstimation.cs
-
2ProjectSettings/ProjectSettings.asset
-
96Assets/Scripts/BasicLightEstimation.cs
-
11Assets/Scripts/HDRLightEstimation.cs.meta
-
0/Assets/Scripts/BasicLightEstimation.cs.meta
-
0/Assets/Scripts/HDRLightEstimation.cs
|
|||
using UnityEngine; |
|||
using UnityEngine.Rendering; |
|||
using UnityEngine.XR.ARFoundation; |
|||
|
|||
namespace UnityEngine.XR.ARFoundation.Samples |
|||
{ |
|||
/// <summary>
|
|||
/// A component that can be used to access the most
|
|||
/// recently received light estimation information
|
|||
/// for the physical environment as observed by an
|
|||
/// AR device.
|
|||
/// </summary>
|
|||
[RequireComponent(typeof(Light))] |
|||
public class BasicLightEstimation : MonoBehaviour |
|||
{ |
|||
[SerializeField] |
|||
[Tooltip("The ARCameraManager which will produce frame events containing light estimation information.")] |
|||
ARCameraManager m_CameraManager; |
|||
|
|||
/// <summary>
|
|||
/// Get or set the <c>ARCameraManager</c>.
|
|||
/// </summary>
|
|||
public ARCameraManager cameraManager |
|||
{ |
|||
get { return m_CameraManager; } |
|||
set |
|||
{ |
|||
if (m_CameraManager == value) |
|||
return; |
|||
|
|||
if (m_CameraManager != null) |
|||
m_CameraManager.frameReceived -= FrameChanged; |
|||
|
|||
m_CameraManager = value; |
|||
|
|||
if (m_CameraManager != null & enabled) |
|||
m_CameraManager.frameReceived += FrameChanged; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// The estimated brightness of the physical environment, if available.
|
|||
/// </summary>
|
|||
public float? brightness { get; private set; } |
|||
|
|||
/// <summary>
|
|||
/// The estimated color temperature of the physical environment, if available.
|
|||
/// </summary>
|
|||
public float? colorTemperature { get; private set; } |
|||
|
|||
/// <summary>
|
|||
/// The estimated color correction value of the physical environment, if available.
|
|||
/// </summary>
|
|||
public Color? colorCorrection { get; private set; } |
|||
|
|||
void Awake () |
|||
{ |
|||
m_Light = GetComponent<Light>(); |
|||
} |
|||
|
|||
void OnEnable() |
|||
{ |
|||
if (m_CameraManager != null) |
|||
m_CameraManager.frameReceived += FrameChanged; |
|||
} |
|||
|
|||
void OnDisable() |
|||
{ |
|||
if (m_CameraManager != null) |
|||
m_CameraManager.frameReceived -= FrameChanged; |
|||
} |
|||
|
|||
void FrameChanged(ARCameraFrameEventArgs args) |
|||
{ |
|||
if (args.lightEstimation.averageBrightness.HasValue) |
|||
{ |
|||
brightness = args.lightEstimation.averageBrightness.Value; |
|||
m_Light.intensity = brightness.Value; |
|||
} |
|||
|
|||
if (args.lightEstimation.averageColorTemperature.HasValue) |
|||
{ |
|||
colorTemperature = args.lightEstimation.averageColorTemperature.Value; |
|||
m_Light.colorTemperature = colorTemperature.Value; |
|||
} |
|||
|
|||
if (args.lightEstimation.colorCorrection.HasValue) |
|||
{ |
|||
colorCorrection = args.lightEstimation.colorCorrection.Value; |
|||
m_Light.color = colorCorrection.Value; |
|||
} |
|||
} |
|||
|
|||
Light m_Light; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 847c0b77d9dc643c796f10eb8a022199 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue