Add UI Widget to new asset creation for quick UI setup
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using FlaxEditor.Content.Thumbnails;
|
||||
using FlaxEditor.Viewport.Previews;
|
||||
using FlaxEditor.Windows;
|
||||
@@ -194,4 +195,64 @@ namespace FlaxEditor.Content
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Content proxy for quick UI Control prefab creation as widget.
|
||||
/// </summary>
|
||||
[ContentContextMenu("New/Widget")]
|
||||
internal sealed class WidgetProxy : AssetProxy
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Name => "UI Widget";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsProxyFor(ContentItem item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string FileExtension => PrefabProxy.Extension;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override EditorWindow Open(Editor editor, ContentItem item)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Color AccentColor => Color.Transparent;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string TypeName => PrefabProxy.AssetTypename;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override AssetItem ConstructItem(string path, string typeName, ref Guid id)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanCreate(ContentFolder targetLocation)
|
||||
{
|
||||
return targetLocation.CanHaveAssets;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Create(string outputPath, object arg)
|
||||
{
|
||||
// Create prefab with UI Control
|
||||
var actor = new UIControl
|
||||
{
|
||||
Name = Path.GetFileNameWithoutExtension(outputPath),
|
||||
StaticFlags = StaticFlags.None,
|
||||
};
|
||||
actor.Control = new Button
|
||||
{
|
||||
Text = "Button",
|
||||
};
|
||||
PrefabManager.CreatePrefab(actor, outputPath, false);
|
||||
Object.Destroy(actor, 20.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1106,6 +1106,7 @@ namespace FlaxEditor.Modules
|
||||
Proxy.Add(new VisualScriptProxy());
|
||||
Proxy.Add(new BehaviorTreeProxy());
|
||||
Proxy.Add(new LocalizedStringTableProxy());
|
||||
Proxy.Add(new WidgetProxy());
|
||||
Proxy.Add(new FileProxy());
|
||||
Proxy.Add(new SpawnableJsonAssetProxy<PhysicalMaterial>());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user