iFactory.Godot/addons/BITPlugins/InspectorPlugins.cs

40 lines
776 B
C#

using Godot;
using System;
using System.Reflection;
namespace BITKit;
#if TOOLS
using Godot;
[Tool]
public partial class InspectorPlugins : EditorInspectorPlugin
{
public override bool _CanHandle(GodotObject @object)
{
return @object is Node;
}
public override bool _ParseProperty(
GodotObject @object,
Variant.Type type,
string name,
PropertyHint hintType,
string hintString,
PropertyUsageFlags usageFlags, bool wide)
{
switch (type)
{
case Variant.Type.String:
var field = @object.GetType().GetField(name);
var att = field?.GetCustomAttribute<ReadOnlyAttribute>();
if (att is null) return false;
var label = new Label();
AddPropertyEditor(name, label);
break;
default:
return false;
}
return true;
}
}
#endif