aboutsummaryrefslogtreecommitdiff
path: root/tools/editor/plugins
diff options
context:
space:
mode:
authorJuan Linietsky2016-02-27 23:10:44 -0300
committerJuan Linietsky2016-02-27 23:12:27 -0300
commit6fc1c3a4d1cf0c865f7dfdb1221ef07a5d25f305 (patch)
treef3871d453b8dafac043cdb3a7488717f3170be77 /tools/editor/plugins
parenta97c1ca8f9f22aca758ebc778d8eb34b3f9ccc39 (diff)
downloadgodot-6fc1c3a4d1cf0c865f7dfdb1221ef07a5d25f305.tar.gz
godot-6fc1c3a4d1cf0c865f7dfdb1221ef07a5d25f305.tar.zst
godot-6fc1c3a4d1cf0c865f7dfdb1221ef07a5d25f305.zip
Completed the support for plugins! It is not possible to add plugins.
Not all APIs are provided yet, please request whathever you are missing. Some example plugins are provided in demos/plugins. Just copy them to a folder in your project named addons/ and then enable them from the project settings. Have fun!
Diffstat (limited to 'tools/editor/plugins')
-rw-r--r--tools/editor/plugins/path_editor_plugin.cpp12
-rw-r--r--tools/editor/plugins/path_editor_plugin.h6
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.cpp29
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.h4
4 files changed, 21 insertions, 30 deletions
diff --git a/tools/editor/plugins/path_editor_plugin.cpp b/tools/editor/plugins/path_editor_plugin.cpp
index b99e63260..3c4428bdb 100644
--- a/tools/editor/plugins/path_editor_plugin.cpp
+++ b/tools/editor/plugins/path_editor_plugin.cpp
@@ -267,17 +267,15 @@ PathSpatialGizmo::PathSpatialGizmo(Path* p_path){
}
-bool PathEditorPlugin::create_spatial_gizmo(Spatial* p_spatial) {
+Ref<SpatialEditorGizmo> PathEditorPlugin::create_spatial_gizmo(Spatial* p_spatial) {
- if (p_spatial->cast_to<Path>()) {
+ if (p_spatial->cast_to<Path>()) {
- Ref<PathSpatialGizmo> psg = memnew( PathSpatialGizmo(p_spatial->cast_to<Path>()));
- p_spatial->set_gizmo(psg);
- return true;
+ return memnew( PathSpatialGizmo(p_spatial->cast_to<Path>()));
}
- return false;
+ return Ref<SpatialEditorGizmo>();
}
bool PathEditorPlugin::forward_spatial_input_event(Camera* p_camera,const InputEvent& p_event) {
@@ -538,7 +536,7 @@ PathEditorPlugin::PathEditorPlugin(EditorNode *p_node) {
path_thin_material->set_flag(Material::FLAG_DOUBLE_SIDED,true);
path_thin_material->set_flag(Material::FLAG_UNSHADED,true);
- SpatialEditor::get_singleton()->add_gizmo_plugin(this);
+// SpatialEditor::get_singleton()->add_gizmo_plugin(this);
sep = memnew( VSeparator);
sep->hide();
diff --git a/tools/editor/plugins/path_editor_plugin.h b/tools/editor/plugins/path_editor_plugin.h
index 18bad23bd..0afd957af 100644
--- a/tools/editor/plugins/path_editor_plugin.h
+++ b/tools/editor/plugins/path_editor_plugin.h
@@ -32,9 +32,9 @@
#include "tools/editor/spatial_editor_gizmos.h"
#include "scene/3d/path.h"
-class PathSpatialGizmo : public SpatialGizmoTool {
+class PathSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(PathSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(PathSpatialGizmo,EditorSpatialGizmo);
Path* path;
mutable Vector3 original;
@@ -83,7 +83,7 @@ public:
virtual bool forward_spatial_input_event(Camera* p_camera,const InputEvent& p_event);
// virtual bool forward_input_event(const InputEvent& p_event) { return collision_polygon_editor->forward_input_event(p_event); }
- virtual bool create_spatial_gizmo(Spatial* p_spatial);
+ virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial* p_spatial);
virtual String get_name() const { return "Path"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp
index bc57fd7e4..1f264a233 100644
--- a/tools/editor/plugins/spatial_editor_plugin.cpp
+++ b/tools/editor/plugins/spatial_editor_plugin.cpp
@@ -3655,35 +3655,32 @@ void SpatialEditor::_request_gizmo(Object* p_obj) {
Spatial *sp=p_obj->cast_to<Spatial>();
if (!sp)
return;
- if (editor->get_edited_scene() && (sp==editor->get_edited_scene() || sp->get_owner()==editor->get_edited_scene())) {
+ if (editor->get_edited_scene() && (sp==editor->get_edited_scene() || sp->get_owner()==editor->get_edited_scene() || editor->get_edited_scene()->is_editable_instance(sp->get_owner()))) {
- Ref<SpatialEditorGizmo> seg = gizmos->get_gizmo(sp);
+ Ref<SpatialEditorGizmo> seg;
- if (seg.is_valid()) {
- sp->set_gizmo(seg);
- }
-
- for (List<EditorPlugin*>::Element *E=gizmo_plugins.front();E;E=E->next()) {
+ for(int i=0;i<EditorNode::get_singleton()->get_editor_data().get_editor_plugin_count();i++) {
- if (E->get()->create_spatial_gizmo(sp)) {
+ seg = EditorNode::get_singleton()->get_editor_data().get_editor_plugin(i)->create_spatial_gizmo(sp);
+ if (seg.is_valid())
+ break;
+ }
- seg = sp->get_gizmo();
- if (sp==selected && seg.is_valid()) {
+ if (!seg.is_valid()) {
+ seg = gizmos->get_gizmo(sp);
+ }
- seg->set_selected(true);
- selected->update_gizmo();
- }
- return;
- }
+ if (seg.is_valid()) {
+ sp->set_gizmo(seg);
}
+
if (seg.is_valid() && sp==selected) {
seg->set_selected(true);
selected->update_gizmo();
}
}
-
}
void SpatialEditor::_toggle_maximize_view(Object* p_viewport) {
diff --git a/tools/editor/plugins/spatial_editor_plugin.h b/tools/editor/plugins/spatial_editor_plugin.h
index b0e366b14..af1b6919a 100644
--- a/tools/editor/plugins/spatial_editor_plugin.h
+++ b/tools/editor/plugins/spatial_editor_plugin.h
@@ -457,8 +457,6 @@ private:
Ref<Environment> viewport_environment;
- List<EditorPlugin*> gizmo_plugins;
-
Spatial *selected;
void _request_gizmo(Object* p_obj);
@@ -518,8 +516,6 @@ public:
UndoRedo *get_undo_redo() { return undo_redo; }
- void add_gizmo_plugin(EditorPlugin* p_plugin) { gizmo_plugins.push_back(p_plugin); }
-
void add_control_to_menu_panel(Control *p_control);
VSplitContainer *get_shader_split();