浏览代码

[XR] Fix warnings in Editor

Add public properties to silence the warnings in the Editor concerning values that are never set and will always be null (they are set in the UI, so they are generally not null).
/1.5-preview
Tim Mowrer 6 年前
当前提交
1526268b
共有 4 个文件被更改,包括 115 次插入35 次删除
  1. 76
      Assets/Scripts/ARWorldMapController.cs
  2. 9
      Assets/Scripts/DisableVerticalPlanes.cs
  3. 51
      Assets/Scripts/LightEstimationUI.cs
  4. 14
      Assets/Scripts/PlaneDetectionController.cs

76
Assets/Scripts/ARWorldMapController.cs


[SerializeField]
ARSession m_ARSession;
public ARSession arSession
{
get { return m_ARSession; }
set { m_ARSession = value; }
}
public Text errorText
{
get { return m_ErrorText; }
set { m_ErrorText = value; }
}
public Button saveButton
{
get { return m_SaveButton; }
set { m_SaveButton = value; }
}
public Button loadButton
{
get { return m_LoadButton; }
set { m_LoadButton = value; }
}
public Text logText
{
get { return m_LogText; }
set { m_LogText = value; }
}
Text m_MappingStatus;
Text m_MappingStatusText;
public Text mappingStatusText
{
get { return m_MappingStatusText; }
set { m_MappingStatusText = value; }
}
/// <summary>
/// Create an <c>ARWorldMap</c> and save it to disk.

m_LogMessages.Add(logMessage);
}
void SetActive(Button button, bool active)
{
if (button != null)
button.gameObject.SetActive(active);
}
void SetActive(Text text, bool active)
{
if (text != null)
text.gameObject.SetActive(active);
}
void SetText(Text text, string value)
{
if (text != null)
text.text = value;
}
m_ErrorText.gameObject.SetActive(false);
m_SaveButton.gameObject.SetActive(true);
m_LoadButton.gameObject.SetActive(true);
m_MappingStatus.gameObject.SetActive(true);
SetActive(errorText, false);
SetActive(saveButton, true);
SetActive(loadButton, true);
SetActive(mappingStatusText, true);
m_ErrorText.gameObject.SetActive(true);
m_SaveButton.gameObject.SetActive(false);
m_LoadButton.gameObject.SetActive(false);
m_MappingStatus.gameObject.SetActive(false);
SetActive(errorText, true);
SetActive(saveButton, false);
SetActive(loadButton, false);
SetActive(mappingStatusText, false);
}
var sessionSubsystem = ARSubsystemManager.sessionSubsystem;

msg += m_LogMessages[i];
msg += "\n";
}
m_LogText.text = msg;
SetText(logText, msg);
m_MappingStatus.text = string.Format("Mapping Status: {0}", sessionSubsystem.GetWorldMappingStatus());
SetText(mappingStatusText, string.Format("Mapping Status: {0}", sessionSubsystem.GetWorldMappingStatus()));
#endif
}

9
Assets/Scripts/DisableVerticalPlanes.cs


[SerializeField]
Text m_LogText;
public Text logText
{
get { return m_LogText; }
set { m_LogText = value; }
}
void OnEnable()
{
GetComponent<ARPlaneManager>().planeAdded += OnPlaneAdded;

plane.gameObject.SetActive(false);
// Add to our log so the user knows something happened.
m_LogText.text += string.Format("\n{0}", plane.boundedPlane.Id);
if (logText != null)
logText.text = string.Format("\n{0}", plane.boundedPlane.Id);
}
}
}

51
Assets/Scripts/LightEstimationUI.cs


public class LightEstimationUI : MonoBehaviour
{
[SerializeField]
Text m_BrightnessVal;
Text m_BrightnessText;
public Text brightnessText
{
get { return m_BrightnessText; }
set { m_BrightnessText = brightnessText; }
}
Text m_ColorTempVal;
Text m_ColorTemperatureText;
public Text colorTemperatureText
{
get { return m_ColorTemperatureText; }
set { m_ColorTemperatureText = value; }
}
Text m_ColorCorrectVal;
Text m_ColorCorrectionText;
public Text colorCorrectionText
{
get { return m_ColorCorrectionText; }
set { m_ColorCorrectionText = value; }
}
LightEstimation m_LightEstimation;

void Update()
{
SetUIValue(m_LightEstimation.brightness, m_BrightnessVal);
SetUIValue(m_LightEstimation.colorTemperature, m_ColorTempVal);
SetUIValue(m_LightEstimation.colorCorrection, m_ColorCorrectVal);
SetUIValue(m_LightEstimation.brightness, brightnessText);
SetUIValue(m_LightEstimation.colorTemperature, colorTemperatureText);
SetUIValue(m_LightEstimation.colorCorrection, colorCorrectionText);
void SetUIValue<T>(T? displayVar, Text uiText) where T : struct
void SetUIValue<T>(T? displayValue, Text text) where T : struct
if (uiText)
{
if (displayVar.HasValue)
{
uiText.text = displayVar.Value.ToString();
}
else
{
uiText.text = k_UnavailableText;
}
}
if (text != null)
text.text = displayValue.HasValue ? displayValue.Value.ToString()
: k_UnavailableText;
}

14
Assets/Scripts/PlaneDetectionController.cs


[SerializeField]
Text m_TogglePlaneDetectionText;
public Text togglePlaneDetectionText
{
get { return m_TogglePlaneDetectionText; }
set { m_TogglePlaneDetectionText = value; }
}
/// <summary>
/// Toggles plane detection and the visualization of the planes.
/// </summary>

string planeDetectionMessage = "";
m_TogglePlaneDetectionText.text = "Disable Plane Detection and Hide Existing";
planeDetectionMessage = "Disable Plane Detection and Hide Existing";
m_TogglePlaneDetectionText.text = "Enable Plane Detection and Show Existing";
planeDetectionMessage = "Enable Plane Detection and Show Existing";
if (togglePlaneDetectionText != null)
togglePlaneDetectionText.text = planeDetectionMessage;
}
/// <summary>

正在加载...
取消
保存