@@ -407,20 +407,13 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
/// <seealso cref="FlaxEditor.CustomEditors.Editors.GenericEditor" />
|
/// <seealso cref="FlaxEditor.CustomEditors.Editors.GenericEditor" />
|
||||||
public class UIControlControlEditor : GenericEditor
|
public class UIControlControlEditor : GenericEditor
|
||||||
{
|
{
|
||||||
private Type _cachedType;
|
private ScriptType[] _valueTypes;
|
||||||
private bool _anchorDropDownClosed = true;
|
private bool _anchorDropDownClosed = true;
|
||||||
private Button _pivotRelativeButton;
|
private Button _pivotRelativeButton;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Initialize(LayoutElementsContainer layout)
|
public override void Initialize(LayoutElementsContainer layout)
|
||||||
{
|
{
|
||||||
_cachedType = null;
|
|
||||||
if (HasDifferentTypes)
|
|
||||||
{
|
|
||||||
// TODO: support stable editing multiple different control types (via generic way or for transform-only)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set control type button
|
// Set control type button
|
||||||
var space = layout.Space(20);
|
var space = layout.Space(20);
|
||||||
var buttonText = "Set Type";
|
var buttonText = "Set Type";
|
||||||
@@ -445,12 +438,12 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add control type helper label
|
// Add control type helper label
|
||||||
|
if (!Values.HasDifferentTypes)
|
||||||
{
|
{
|
||||||
var type = Values[0].GetType();
|
|
||||||
_cachedType = type;
|
|
||||||
var label = layout.AddPropertyItem("Type", "The type of the created control.");
|
var label = layout.AddPropertyItem("Type", "The type of the created control.");
|
||||||
label.Label(type.FullName);
|
label.Label(Values[0].GetType().FullName);
|
||||||
}
|
}
|
||||||
|
_valueTypes = Values.ValuesTypes;
|
||||||
|
|
||||||
// Show control properties
|
// Show control properties
|
||||||
base.Initialize(layout);
|
base.Initialize(layout);
|
||||||
@@ -720,22 +713,20 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Refresh()
|
public override void Refresh()
|
||||||
{
|
{
|
||||||
if (_cachedType != null)
|
// Automatic layout rebuild if control type gets changed
|
||||||
|
if (_valueTypes != null &&
|
||||||
|
!Values.HasNull &&
|
||||||
|
!Utils.ArraysEqual(_valueTypes, Values.ValuesTypes))
|
||||||
{
|
{
|
||||||
// Automatic layout rebuild if control type gets changed
|
RebuildLayout();
|
||||||
var type = Values.HasNull ? null : Values[0].GetType();
|
return;
|
||||||
if (type != _cachedType)
|
}
|
||||||
{
|
|
||||||
RebuildLayout();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Refresh anchors
|
// Refresh anchors
|
||||||
GetAnchorEquality(out bool xEq, out bool yEq, ValuesTypes);
|
GetAnchorEquality(out bool xEq, out bool yEq, ValuesTypes);
|
||||||
if (xEq != _cachedXEq || yEq != _cachedYEq)
|
if (xEq != _cachedXEq || yEq != _cachedYEq)
|
||||||
{
|
{
|
||||||
RebuildLayout();
|
RebuildLayout();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
base.Refresh();
|
base.Refresh();
|
||||||
|
|||||||
Reference in New Issue
Block a user