您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

67 行
2.2 KiB

using UnityEngine;
using UnityEngine.UI;
using System.Text;
using UnityEngine.Rendering;
namespace UnityEngine.XR.ARFoundation.Samples
{
/// <summary>
/// A simple UI controller to display light estimation information.
/// </summary>
[RequireComponent(typeof(LightEstimation))]
public class LightEstimationUI : MonoBehaviour
{
[Tooltip("The UI Text element used to display the estimated ambient intensity in the physical environment.")]
[SerializeField]
Text m_AmbientIntensityText;
/// <summary>
/// The UI Text element used to display the estimated ambient intensity value.
/// </summary>
public Text ambientIntensityText
{
get { return m_AmbientIntensityText; }
set { m_AmbientIntensityText = ambientIntensityText; }
}
[Tooltip("The UI Text element used to display the estimated ambient color in the physical environment.")]
[SerializeField]
Text m_AmbientColorText;
/// <summary>
/// The UI Text element used to display the estimated color temperature in the scene.
/// </summary>
public Text ambientColorText
{
get { return m_AmbientColorText; }
set { m_AmbientColorText = value; }
}
void Awake()
{
m_LightEstimation = GetComponent<LightEstimation>();
}
void Update()
{
SetUIValue(m_LightEstimation.brightness, ambientIntensityText);
//Display either color temperature or color correction if supported
if (m_LightEstimation.colorTemperature != null)
SetUIValue(m_LightEstimation.colorTemperature, ambientColorText);
else
SetUIValue(m_LightEstimation.colorCorrection, ambientColorText);
}
void SetUIValue<T>(T? displayValue, Text text) where T : struct
{
if (text != null)
text.text = displayValue.HasValue ? displayValue.Value.ToString(): k_UnavailableText;
}
const string k_UnavailableText = "Unavailable";
LightEstimation m_LightEstimation;
}
}