mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-02-07 21:21:32 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
30 lines
527 B
C#
30 lines
527 B
C#
using System.Text.Json.Nodes;
|
|
|
|
namespace Editor;
|
|
|
|
public static class SceneEditor
|
|
{
|
|
/// <summary>
|
|
/// Is there a <see cref="Component"/> type in the clipboard?
|
|
/// </summary>
|
|
public static bool HasComponentInClipboard()
|
|
{
|
|
var text = EditorUtility.Clipboard.Paste();
|
|
|
|
try
|
|
{
|
|
if ( JsonNode.Parse( text ) is JsonObject jso )
|
|
{
|
|
var componentType = TypeLibrary.GetType<Component>( (string)jso["__type"] );
|
|
return componentType is not null;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
// Do nothing.
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|