iFactory.Godot/addons/BITPlugins/InspectorPlugins.cs

40 lines
776 B
C#
Raw Normal View History

2023-07-17 04:10:14 +08:00
using Godot;
using System;
2023-07-18 16:42:33 +08:00
using System.Reflection;
2023-07-17 04:10:14 +08:00
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)
{
2023-07-18 16:42:33 +08:00
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;
}
2023-07-17 04:10:14 +08:00
return true;
}
}
#endif