This commit is contained in:
CortexCore
2023-07-18 16:42:33 +08:00
parent 5f6975ca67
commit 37f46e6d16
25 changed files with 335 additions and 105 deletions

View File

@@ -1,5 +1,6 @@
using Godot;
using System;
using System.Reflection;
namespace BITKit;
#if TOOLS
@@ -20,13 +21,18 @@ public partial class InspectorPlugins : EditorInspectorPlugin
string hintString,
PropertyUsageFlags usageFlags, bool wide)
{
// We handle properties of type integer.
if (type != Variant.Type.Int) return false;
// Create an instance of the custom property editor and register
// it to a specific property path.
AddPropertyEditor(name, new RandomIntEditor());
// Inform the editor to remove the default property editor for
// this property type.
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;
}
}