Merge branch 'GoaLitiuM-customeditor_fixes'

This commit is contained in:
Wojtek Figat
2024-07-25 08:38:41 +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;
return true;
@@ -676,20 +676,7 @@ namespace FlaxEditor.CustomEditors
/// <summary>
/// Gets a value indicating whether can paste value from the system clipboard to the property value container.
/// </summary>
public bool CanPaste
{
get
{
try
{
return GetClipboardObject(out _, false);
}
catch
{
return false;
}
}
}
public bool CanPaste => !string.IsNullOrEmpty(Clipboard.Text);
/// <summary>
/// Sets the value from the system clipboard.

View File

@@ -474,32 +474,7 @@ namespace FlaxEditor.CustomEditors.Editors
}
if (layout.Editors.Count != 0)
{
var sb = 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;
return !string.IsNullOrEmpty(Clipboard.Text);
}
if (layout.Children.Any(x => x is LayoutElementsContainer))
{

View File

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