Replicated the weapon flying tick setup using resources
This commit is contained in:
@@ -6,7 +6,7 @@ using Godot;
|
||||
namespace Gamesmiths.Forge.Godot.Editor.Attributes;
|
||||
|
||||
[Tool]
|
||||
public partial class AttributeEditorProperty : EditorProperty
|
||||
public partial class AttributeEditorProperty : EditorProperty, ISerializationListener
|
||||
{
|
||||
private const int ButtonSize = 26;
|
||||
private const int PopupSize = 300;
|
||||
@@ -15,17 +15,15 @@ public partial class AttributeEditorProperty : EditorProperty
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Texture2D dropdownIcon = EditorInterface.Singleton
|
||||
.GetEditorTheme()
|
||||
.GetIcon("GuiDropdown", "EditorIcons");
|
||||
Texture2D dropdownIcon = EditorInterface.Singleton.GetEditorTheme().GetIcon("GuiDropdown", "EditorIcons");
|
||||
|
||||
var hbox = new HBoxContainer();
|
||||
var hBox = new HBoxContainer();
|
||||
_label = new Label { Text = "None", SizeFlagsHorizontal = SizeFlags.ExpandFill };
|
||||
var button = new Button { Icon = dropdownIcon, CustomMinimumSize = new Vector2(ButtonSize, 0) };
|
||||
|
||||
hbox.AddChild(_label);
|
||||
hbox.AddChild(button);
|
||||
AddChild(hbox);
|
||||
hBox.AddChild(_label);
|
||||
hBox.AddChild(button);
|
||||
AddChild(hBox);
|
||||
|
||||
var popup = new Popup { Size = new Vector2I(PopupSize, PopupSize) };
|
||||
var tree = new Tree
|
||||
@@ -78,6 +76,20 @@ public partial class AttributeEditorProperty : EditorProperty
|
||||
_label.Text = string.IsNullOrEmpty(value) ? "None" : value;
|
||||
}
|
||||
|
||||
public void OnBeforeSerialize()
|
||||
{
|
||||
for (var i = GetChildCount() - 1; i >= 0; i--)
|
||||
{
|
||||
Node child = GetChild(i);
|
||||
RemoveChild(child);
|
||||
child.Free();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnAfterDeserialize()
|
||||
{
|
||||
}
|
||||
|
||||
private static void BuildAttributeTree(Tree tree)
|
||||
{
|
||||
TreeItem root = tree.CreateItem();
|
||||
|
||||
Reference in New Issue
Block a user