您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
47 行
1.1 KiB
47 行
1.1 KiB
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_UnavailableText = "Unavailable";
|
|
|
|
void Awake()
|
|
{
|
|
m_LightEstimation = GetComponent<LightEstimation>();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
SetUIValue(m_LightEstimation.brightness, m_BrightnessVal);
|
|
SetUIValue(m_LightEstimation.colorTemperature, m_ColorTempVal);
|
|
SetUIValue(m_LightEstimation.colorCorrection, m_ColorCorrectVal);
|
|
}
|
|
|
|
void SetUIValue<T>(T? displayVar, Text uiText) where T : struct
|
|
{
|
|
if (uiText)
|
|
{
|
|
if (displayVar.HasValue)
|
|
{
|
|
uiText.text = displayVar.Value.ToString();
|
|
}
|
|
else
|
|
{
|
|
uiText.text = k_UnavailableText;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|