您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
56 行
1.4 KiB
56 行
1.4 KiB
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
[RequireComponent(typeof(LightEstimation))]
|
|
public class LightEstimationUI : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
Text m_BrightnessText;
|
|
|
|
public Text brightnessText
|
|
{
|
|
get { return m_BrightnessText; }
|
|
set { m_BrightnessText = brightnessText; }
|
|
}
|
|
|
|
[SerializeField]
|
|
Text m_ColorTemperatureText;
|
|
|
|
public Text colorTemperatureText
|
|
{
|
|
get { return m_ColorTemperatureText; }
|
|
set { m_ColorTemperatureText = value; }
|
|
}
|
|
|
|
[SerializeField]
|
|
Text m_ColorCorrectionText;
|
|
|
|
public Text colorCorrectionText
|
|
{
|
|
get { return m_ColorCorrectionText; }
|
|
set { m_ColorCorrectionText = value; }
|
|
}
|
|
|
|
LightEstimation m_LightEstimation;
|
|
|
|
const string k_UnavailableText = "Unavailable";
|
|
|
|
void Awake()
|
|
{
|
|
m_LightEstimation = GetComponent<LightEstimation>();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
SetUIValue(m_LightEstimation.brightness, brightnessText);
|
|
SetUIValue(m_LightEstimation.colorTemperature, colorTemperatureText);
|
|
SetUIValue(m_LightEstimation.colorCorrection, colorCorrectionText);
|
|
}
|
|
|
|
void SetUIValue<T>(T? displayValue, Text text) where T : struct
|
|
{
|
|
if (text != null)
|
|
text.text = displayValue.HasValue ? displayValue.Value.ToString()
|
|
: k_UnavailableText;
|
|
}
|
|
}
|