调整了模板

This commit is contained in:
CortexCore
2023-07-17 04:10:14 +08:00
parent 498b0617f8
commit e27cce2ac3
56 changed files with 2165 additions and 581 deletions

View File

@@ -0,0 +1,33 @@
using Godot;
using System;
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)
{
// 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.
return true;
}
}
#endif

View File

@@ -0,0 +1,63 @@
using Godot;
using System;
namespace BITKit;
#if TOOLS
using Godot;
[Tool]
public partial class RandomIntEditor : EditorProperty
{
// The main control for editing the property.
private Button _propertyControl = new Button();
// An internal value of the property.
private int _currentValue = 0;
// A guard against internal changes when the property is updated.
private bool _updating = false;
public RandomIntEditor()
{
// Add the control as a direct child of EditorProperty node.
AddChild(_propertyControl);
// Make sure the control is able to retain the focus.
AddFocusable(_propertyControl);
// Setup the initial state and connect to the signal to track changes.
RefreshControlText();
//_propertyControl.Connect("pressed", this, nameof(OnButtonPressed));
}
private void OnButtonPressed()
{
// Ignore the signal if the property is currently being updated.
if (_updating)
{
return;
}
// Generate a new random integer between 0 and 99.
_currentValue = (int)GD.Randi() % 100;
RefreshControlText();
EmitChanged(GetEditedProperty(), _currentValue);
}
public override void _UpdateProperty()
{
// Read the current value from the property.
var newValue = (int)GetEditedObject().Get(GetEditedProperty());
if (newValue == _currentValue)
{
return;
}
// Update the control with the new value.
_updating = true;
_currentValue = newValue;
RefreshControlText();
_updating = false;
}
private void RefreshControlText()
{
_propertyControl.Text = $"Value: {_currentValue}";
}
}
#endif

View File

@@ -1,18 +0,0 @@
#if TOOLS
using Godot;
namespace BITKit;
[Tool]
public partial class RefencePlugin : EditorPlugin
{
public override void _EnterTree()
{
// Initialization of the plugin goes here.
}
public override void _ExitTree()
{
// Clean-up of the plugin goes here.
}
}
#endif

View File

@@ -0,0 +1,24 @@
[gd_scene load_steps=2 format=3 uid="uid://r7xpryghff3b"]
[ext_resource type="Script" path="res://addons/BITPlugins/ReferenceExamples.cs" id="1_h7isd"]
[node name="ReferenceContainer" type="PanelContainer"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_h7isd")
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
text = "引用插件"
[node name="Node" type="Node" parent="."]
script = ExtResource("1_h7isd")

View File

@@ -0,0 +1,8 @@
using Godot;
using System;
namespace BITKit;
public partial class ReferenceExamples : Node
{
}

View File

@@ -0,0 +1,23 @@
using Godot;
using System;
#if TOOLS
namespace BITKit;
[Tool]
public partial class ReferencePlugins : EditorPlugin
{
private InspectorPlugins _plugin;
private PackedScene _containerTemplate = GD.Load<PackedScene>("res://addons/BITPlugins/ReferenceContainer.tscn");
public override void _EnterTree()
{
_plugin = new InspectorPlugins();
AddInspectorPlugin(_plugin);
}
public override void _ExitTree()
{
RemoveInspectorPlugin(_plugin);
}
}
#endif

View File

@@ -1,18 +0,0 @@
using Godot;
namespace BITKit;
#if TOOLS
[Tool]
public partial class RegistryPlugin : EditorPlugin
{
public override void _EnterTree()
{
// var type = typeof(StringResource);
// const string classPath = "res://Artists/Scripts/Resource/StringResource.cs";
// var script = GD.Load<Script>(classPath);
// GD.Print($"已加载{script.ResourceName??script.ToString()}");
// AddCustomType(type.Name, "Resource", script, null);
}
}
#endif

View File

@@ -4,4 +4,4 @@ name="BITPlugins"
description="BITKit为Godot支持的插件 "
author="军火商小火柴"
version=""
script="RegistryPlugin.cs"
script="ReferencePlugins.cs"