Small fixes.
This commit is contained in:
@@ -85,7 +85,7 @@ public class UIControlRefPickerControl : Control
|
||||
|
||||
// Update tooltip
|
||||
if (_value is SceneObject sceneObject)
|
||||
TooltipText = FlaxEditor.Utilities.Utils.GetTooltip(sceneObject);
|
||||
TooltipText = Utilities.Utils.GetTooltip(sceneObject);
|
||||
else
|
||||
TooltipText = string.Empty;
|
||||
|
||||
@@ -93,6 +93,15 @@ public class UIControlRefPickerControl : Control
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the selected object value by identifier.
|
||||
/// </summary>
|
||||
public Guid ValueID
|
||||
{
|
||||
get => _value ? _value.ID : Guid.Empty;
|
||||
set => Value = Object.Find<UIControl>(ref value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UIControlRefPickerControl"/> class.
|
||||
/// </summary>
|
||||
@@ -123,7 +132,7 @@ public class UIControlRefPickerControl : Control
|
||||
|
||||
private bool IsValid(Actor actor)
|
||||
{
|
||||
return actor is UIControl a && a.Control.GetType() == _controlType;
|
||||
return actor == null || actor is UIControl a && a.Control.GetType() == _controlType;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -263,7 +272,7 @@ public class UIControlRefPickerControl : Control
|
||||
_isMouseDown = false;
|
||||
|
||||
// Highlight actor or script reference
|
||||
if (!_hasValidDragOver && !IsDragOver)
|
||||
if (!_hasValidDragOver && !IsDragOver && nameRect.Contains(location))
|
||||
{
|
||||
Actor actor = _value;
|
||||
if (actor != null)
|
||||
@@ -275,7 +284,7 @@ public class UIControlRefPickerControl : Control
|
||||
}
|
||||
else
|
||||
{
|
||||
_linkedTreeNode = FlaxEditor.Editor.Instance.Scene.GetActorNode(actor).TreeNode;
|
||||
_linkedTreeNode = Editor.Instance.Scene.GetActorNode(actor).TreeNode;
|
||||
_linkedTreeNode.ExpandAllParents();
|
||||
Editor.Instance.Windows.SceneWin.SceneTreePanel.ScrollViewTo(_linkedTreeNode, true);
|
||||
_linkedTreeNode.StartHighlight();
|
||||
@@ -455,7 +464,7 @@ public class ControlReferenceEditor : CustomEditor
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Refresh()
|
||||
{
|
||||
@@ -464,9 +473,7 @@ public class ControlReferenceEditor : CustomEditor
|
||||
if (!HasDifferentValues)
|
||||
{
|
||||
if (Values[0] is IControlReference cr)
|
||||
{
|
||||
_element.CustomControl.Value = cr.UIControl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user