浏览代码

Added light estimation script and scene with UI to display values

/1.5-preview
Dan 6 年前
当前提交
f2037191
共有 6 个文件被更改,包括 1161 次插入0 次删除
  1. 1001
      Assets/Scenes/LightEstimation.unity
  2. 7
      Assets/Scenes/LightEstimation.unity.meta
  3. 74
      Assets/Scripts/LightEstimation.cs
  4. 11
      Assets/Scripts/LightEstimation.cs.meta
  5. 57
      Assets/Scripts/LightEstimationUI.cs
  6. 11
      Assets/Scripts/LightEstimationUI.cs.meta

1001
Assets/Scenes/LightEstimation.unity
文件差异内容过多而无法显示
查看文件

7
Assets/Scenes/LightEstimation.unity.meta


fileFormatVersion: 2
guid: 2f0cbc82480584c258f99f0d9e4ba302
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

74
Assets/Scripts/LightEstimation.cs


using UnityEngine;
using UnityEngine.XR.ARFoundation;
[RequireComponent(typeof(Light))]
public class LightEstimation : MonoBehaviour
{
Light m_Light;
/// <summary>
/// The light affected
/// </summary>
public Light Light
{
get { return m_Light; }
set { m_Light = value; }
}
float? m_Brightness;
public float? Brightness
{
get { return m_Brightness; }
}
float? m_ColorTemperature;
public float? ColorTemperature
{
get { return m_ColorTemperature; }
}
Color? m_ColorCorrection;
public Color? ColorCorrection
{
get { return m_ColorCorrection; }
}
void Awake ()
{
m_Light = GetComponent<Light>();
ARSubsystemManager.cameraFrameReceived += FrameChanged;
}
void FrameChanged(ARCameraFrameEventArgs args)
{
if (args.lightEstimation.averageBrightness.HasValue)
{
m_Brightness = args.lightEstimation.averageBrightness.Value;
m_Light.intensity = m_Brightness.Value;
}
if (args.lightEstimation.averageColorTemperature.HasValue)
{
m_ColorTemperature = args.lightEstimation.averageColorTemperature.Value;
m_Light.colorTemperature = m_ColorTemperature.Value;
}
if (args.lightEstimation.colorCorrection.HasValue)
{
m_ColorCorrection = args.lightEstimation.colorCorrection.Value;
m_Light.color = m_ColorCorrection.Value;
}
}
}

11
Assets/Scripts/LightEstimation.cs.meta


fileFormatVersion: 2
guid: 50c11494e9ace475f9dc92e2f907b42c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

57
Assets/Scripts/LightEstimationUI.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(LightEstimation))]
public class LightEstimationUI : MonoBehaviour
{
[SerializeField]
Text m_BrightnessVal;
[SerializeField]
Text m_ColorTempVal;
[SerializeField]
Text m_ColorCorrectVal;
LightEstimation m_LightEstimation;
const string k_UnsupportedText = "Not Supported";
void Awake()
{
m_LightEstimation = GetComponent<LightEstimation>();
}
void Update()
{
if (m_LightEstimation.Brightness.HasValue)
{
m_BrightnessVal.text = m_LightEstimation.Brightness.Value.ToString();
}
else
{
m_BrightnessVal.text = k_UnsupportedText;
}
if (m_LightEstimation.ColorTemperature.HasValue)
{
m_ColorTempVal.text = m_LightEstimation.ColorTemperature.Value.ToString();
}
else
{
m_ColorTempVal.text = k_UnsupportedText;
}
if (m_LightEstimation.ColorCorrection.HasValue)
{
m_ColorCorrectVal.text = m_LightEstimation.ColorCorrection.Value.ToString();
}
else
{
m_ColorCorrectVal.text = k_UnsupportedText;
}
}
}

11
Assets/Scripts/LightEstimationUI.cs.meta


fileFormatVersion: 2
guid: 079fa7fb0f02c4bd28860dd22bf8f5a1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存