Merge branch 'customeditor_fixes' of https://github.com/GoaLitiuM/FlaxEngine into GoaLitiuM-customeditor_fixes

This commit is contained in:
Wojtek Figat
2024-07-25 08:38:32 +02:00
3 changed files with 13 additions and 51 deletions

View File

@@ -664,7 +664,7 @@ namespace FlaxEditor.CustomEditors
} }
} }
if (obj == null || Values.Type.IsInstanceOfType(obj)) if ((obj == null && !Values.Type.IsValueType) || Values.Type.IsInstanceOfType(obj))
{ {
result = obj; result = obj;
return true; return true;
@@ -676,20 +676,7 @@ namespace FlaxEditor.CustomEditors
/// <summary> /// <summary>
/// Gets a value indicating whether can paste value from the system clipboard to the property value container. /// Gets a value indicating whether can paste value from the system clipboard to the property value container.
/// </summary> /// </summary>
public bool CanPaste public bool CanPaste => !string.IsNullOrEmpty(Clipboard.Text);
{
get
{
try
{
return GetClipboardObject(out _, false);
}
catch
{
return false;
}
}
}
/// <summary> /// <summary>
/// Sets the value from the system clipboard. /// Sets the value from the system clipboard.

View File

@@ -474,32 +474,7 @@ namespace FlaxEditor.CustomEditors.Editors
} }
if (layout.Editors.Count != 0) if (layout.Editors.Count != 0)
{ {
var sb = Clipboard.Text; return !string.IsNullOrEmpty(Clipboard.Text);
if (!string.IsNullOrEmpty(sb))
{
try
{
var data = JsonSerializer.Deserialize<string[]>(sb);
if (data == null || data.Length != layout.Editors.Count)
return false;
for (var i = 0; i < layout.Editors.Count; i++)
{
Clipboard.Text = data[i];
if (!layout.Editors[i].CanPaste)
return false;
}
return true;
}
catch
{
return false;
}
finally
{
Clipboard.Text = sb;
}
}
return false;
} }
if (layout.Children.Any(x => x is LayoutElementsContainer)) if (layout.Children.Any(x => x is LayoutElementsContainer))
{ {

View File

@@ -190,15 +190,7 @@ namespace FlaxEditor.Surface
if (data == null || data.Length < 2) if (data == null || data.Length < 2)
return false; return false;
try return true;
{
var model = JsonConvert.DeserializeObject<DataModel>(data);
return model?.Nodes != null && model.Nodes.Length != 0;
}
catch (Exception)
{
return false;
}
} }
/// <summary> /// <summary>
@@ -215,7 +207,15 @@ namespace FlaxEditor.Surface
try try
{ {
// Load Mr Json // Load Mr Json
var model = FlaxEngine.Json.JsonSerializer.Deserialize<DataModel>(data); DataModel model;
try
{
model = FlaxEngine.Json.JsonSerializer.Deserialize<DataModel>(data);
}
catch
{
return;
}
if (model.Nodes == null) if (model.Nodes == null)
model.Nodes = new DataModelNode[0]; model.Nodes = new DataModelNode[0];