Merge branch 'master' into 3.1, excluding 3.2+ specific changes
I went through the diff to try to ensure that no 3.2+ specific changes are being backported to the stable branch. I might have missed some things though.
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 333 B |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 9.6 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 18 KiB |
@@ -9,3 +9,4 @@ Editor plugins
|
||||
making_main_screen_plugins
|
||||
import_plugins
|
||||
spatial_gizmos
|
||||
inspector_plugins
|
||||
|
||||
83
tutorials/plugins/editor/inspector_plugins.rst
Normal file
@@ -0,0 +1,83 @@
|
||||
.. _doc_inspector_plugins:
|
||||
|
||||
Inspector Plugins
|
||||
=====================
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
Godot 3.1 comes with a new inspector. Adding plugins to it is now possible.
|
||||
|
||||
This tutorial will explain the process.
|
||||
|
||||
|
||||
Inspector Plugin
|
||||
----------------
|
||||
|
||||
This short tutorial will explain how to make a simple value editor.
|
||||
Create an EditorInspectorPlugin first. This is needed to initialize your plugin.
|
||||
|
||||
|
||||
.. tabs::
|
||||
.. code-tab:: gdscript GDScript
|
||||
|
||||
# MyEditorPlugin.gd
|
||||
|
||||
extends EditorInspectorPlugin
|
||||
|
||||
func can_handle(object):
|
||||
# if only editing a specific type
|
||||
# return object is TheTypeIWant
|
||||
# if everything is supported
|
||||
return true
|
||||
|
||||
func parse_property(object,type,path,hint,hint_text,usage):
|
||||
if (type==TYPE_INT):
|
||||
add_custom_property_editor(path,MyEditor.new())
|
||||
return true # I want this one
|
||||
else:
|
||||
return false
|
||||
|
||||
|
||||
Editor
|
||||
------
|
||||
|
||||
|
||||
Here is an editor for editing integers
|
||||
|
||||
.. tabs::
|
||||
.. code-tab:: gdscript GDScript
|
||||
|
||||
# MyEditor.gd
|
||||
class_name MyEditor
|
||||
|
||||
var updating = false
|
||||
|
||||
func _spin_changed(value):
|
||||
if (updating):
|
||||
return
|
||||
|
||||
emit_changed( get_property(), value )
|
||||
|
||||
func update_property():
|
||||
var new_value = get_edited_object()[ get_edited_property() ]
|
||||
|
||||
updating=true
|
||||
spin.set_value( new_value )
|
||||
updating=false
|
||||
|
||||
var spin = EditorSpinSlider.new() # use the new spin slider
|
||||
func _init():
|
||||
# if you want to put the editor below the label
|
||||
# set_bottom_editor( spin )
|
||||
# else use:
|
||||
add_child( spin )
|
||||
# to remember focus when selected back
|
||||
add_focusable( spin )
|
||||
spin.set_min(0)
|
||||
spin.set_max(1000)
|
||||
spin.connect("value_changed",self,"_spin_changed")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -78,9 +78,9 @@ Let's start by writing our main code. Ideally, we want to end up with a file str
|
||||
main.tscn
|
||||
project.godot
|
||||
|
||||
Open up Godot and create a new project called simple. This will create the simple folder and project.godot file. Then manually create a bin and src subfolder in this folder.
|
||||
Open up Godot and create a new project called simple. This will create the ``simple`` folder and ``project.godot`` file. Then manually create a ``bin`` and ``src`` subfolder in this folder.
|
||||
|
||||
We're going to start by having a look at what our simple.c file contains. Now, for our example here we're making a single C source file without a header to keep things simple. Once you start writing bigger projects it is advisable you break your project up into multiple files. That however falls outside of the scope of this tutorial.
|
||||
We're going to start by having a look at what our ``simple.c`` file contains. Now, for our example here we're making a single C source file without a header to keep things simple. Once you start writing bigger projects it is advisable you break your project up into multiple files. That however falls outside of the scope of this tutorial.
|
||||
|
||||
We'll be looking at the source code bit by bit so all the parts below should all be put together into one big file. I'll explain each section as we add it.
|
||||
|
||||
@@ -225,7 +225,7 @@ The variant we return is destroyed automatically by Godot.
|
||||
|
||||
And that is the whole source code of our module.
|
||||
|
||||
If you add a blank .gdignore file to the src folder, Godot will not try to import the compiler-generated temporary files.
|
||||
If you add a blank ``.gdignore`` file to the src folder, Godot will not try to import the compiler-generated temporary files.
|
||||
|
||||
Compiling
|
||||
---------
|
||||
|
||||
@@ -60,7 +60,7 @@ it is a good idea to add them as Git submodules:
|
||||
git init
|
||||
git submodule add https://github.com/GodotNativeTools/godot-cpp
|
||||
cd godot-cpp
|
||||
git submodule update -- init
|
||||
git submodule update --init
|
||||
|
||||
.. code-tab:: none Godot 3.0
|
||||
|
||||
@@ -69,7 +69,7 @@ it is a good idea to add them as Git submodules:
|
||||
git init
|
||||
git submodule add -b 3.0 https://github.com/GodotNativeTools/godot-cpp
|
||||
cd godot-cpp
|
||||
git submodule update -- init
|
||||
git submodule update --init
|
||||
|
||||
If you decide to just download the repositories or clone them
|
||||
into your project folder, make sure to keep the folder layout identical
|
||||
@@ -137,7 +137,7 @@ libraries that can be compiled into your project stored in ``godot-cpp/bin/``.
|
||||
At some point in the future, compiled binaries will be available,
|
||||
making this step optional.
|
||||
|
||||
.. note:: You may need to add ``bits=64`` to the command on Windows. We're still working on better auto detection.
|
||||
.. note:: You may need to add ``bits=64`` to the command on Windows or Linux. We're still working on better auto detection.
|
||||
|
||||
Creating a simple plugin
|
||||
------------------------
|
||||
|
||||