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

49 行
1.1 KiB

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_UnavailableText = "Unavailable";
void Awake()
{
m_LightEstimation = GetComponent<LightEstimation>();
}
void Update()
{
SetUIValue(m_LightEstimation.brightness.HasValue, m_BrightnessVal, m_LightEstimation.brightness.Value.ToString());
SetUIValue(m_LightEstimation.colorTemperature.HasValue, m_ColorTempVal, m_LightEstimation.colorTemperature.Value.ToString());
SetUIValue(m_LightEstimation.colorCorrection.HasValue, m_ColorCorrectVal, m_LightEstimation.colorTemperature.Value.ToString());
}
void SetUIValue(bool ContainsValue, Text UIText, string DisplayValue)
{
if (UIText)
{
if (ContainsValue)
{
UIText.text = DisplayValue;
}
else
{
UIText.text = k_UnavailableText;
}
}
}
}