Small fixes.

This commit is contained in:
Chandler Cox
2025-01-04 11:45:08 -06:00
parent c79cd82fd4
commit 04fc118ddf
2 changed files with 29 additions and 13 deletions

View File

@@ -36,25 +36,34 @@ public struct ControlReference<T> : IControlReference where T : Control
{
[Serialize, ShowInEditor]
private UIControl _uiControl;
/// <summary>
/// Default constructor for ControlReference;
/// </summary>
public ControlReference()
{
_uiControl = null;
}
/// <inheritdoc />
public Type GetControlType()
{
return typeof(T);
}
/// <summary>
/// The Control attached to the UI Control.
/// </summary>
[HideInEditor]
public T Control
{
get
{
if (_uiControl.Control is T t)
if (_uiControl != null && _uiControl.Control is T t)
return t;
else
{
Debug.LogWarning("Trying to get Control from ControlReference but UIControl.Control is null or UIControl.Control is not the correct type.");
Debug.LogWarning("Trying to get Control from ControlReference but UIControl is null, or UIControl.Control is null, or UIControl.Control is not the correct type.");
return null;
}
}
@@ -85,14 +94,14 @@ public struct ControlReference<T> : IControlReference where T : Control
{
_uiControl = null;
}
/// <summary>
/// The implicit operator for the Control.
/// </summary>
/// <param name="reference">The ControlReference</param>
/// <returns>The Control.</returns>
public static implicit operator T(ControlReference<T> reference) => reference.Control;
/// <summary>
/// The implicit operator for the UIControl
/// </summary>