Newer
Older
DungeonShooting / DungeonShooting_Godot / addons / dungeonShooting_plugin / Plugin.cs
@lijincheng lijincheng on 13 Feb 2023 1 KB 更改工程结构
  1. #if TOOLS
  2. using Godot;
  3.  
  4. namespace Plugin
  5. {
  6. [Tool]
  7. public partial class Plugin : EditorPlugin
  8. {
  9. public static Plugin Instance => _instance;
  10. private static Plugin _instance;
  11.  
  12. private Control dock;
  13.  
  14. public override void _Process(double delta)
  15. {
  16. _instance = this;
  17. }
  18.  
  19. public override void _EnterTree()
  20. {
  21. _instance = this;
  22. var script = GD.Load<Script>("res://src/framework/activity/ActivityObjectTemplate.cs");
  23. var texture = GD.Load<Texture2D>("res://addons/dungeonShooting_plugin/ActivityObject.svg");
  24. AddCustomType("ActivityObjectTemplate", "Node", script, texture);
  25. dock = GD.Load<PackedScene>("res://addons/dungeonShooting_plugin/Automation.tscn").Instantiate<Control>();
  26. AddControlToDock(DockSlot.LeftUr, dock);
  27. }
  28.  
  29. public override void _ExitTree()
  30. {
  31. RemoveCustomType("ActivityObjectTemplate");
  32. RemoveControlFromDocks(dock);
  33. dock.Free();
  34. }
  35.  
  36. /*public override bool Handles(Object @object)
  37. {
  38. if (@object is Node node)
  39. {
  40. node.
  41. GD.Print("node: " + (node.GetScript() == activityObjectTemplateScript));
  42. /*GD.Print("---------------------- 1: " + objectTemplate.Name);
  43. var sp = new Sprite2D();
  44. sp.Name = "Sprite2D";
  45. objectTemplate.AddChild(sp);
  46. sp.Owner = objectTemplate.Owner;#1#
  47. }
  48. return base.Handles(@object);
  49. }*/
  50. }
  51.  
  52. }
  53. #endif