mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-05 22:09:56 +03:00
Apply general code formatting to some pages in the tutorial section
This commit is contained in:
@@ -20,16 +20,19 @@ getting a ``plugin.cfg`` file created, and start with our
|
||||
.. tabs::
|
||||
.. code-tab:: gdscript GDScript
|
||||
# MyEditorPlugin.gd
|
||||
tool
|
||||
extends EditorPlugin
|
||||
|
||||
tool extends EditorPlugin
|
||||
|
||||
var plugin: EditorInspectorPlugin
|
||||
var plugin
|
||||
|
||||
|
||||
func _enter_tree():
|
||||
# EditorInspectorPlugin is a resource, so we use `new()` instead of `instance()`.
|
||||
plugin = preload("res://addons/MyPlugin/MyInspectorPlugin.gd").new()
|
||||
add_inspector_plugin(plugin)
|
||||
|
||||
|
||||
func _exit_tree():
|
||||
remove_inspector_plugin(plugin)
|
||||
|
||||
@@ -53,9 +56,9 @@ overriding or changing existing property editors.
|
||||
.. code-tab:: gdscript GDScript
|
||||
|
||||
# MyInspectorPlugin.gd
|
||||
|
||||
extends EditorInspectorPlugin
|
||||
|
||||
|
||||
func can_handle(object):
|
||||
# Here you can specify which object types (classes) should be handled by
|
||||
# this plugin. For example if the plugin is specific to your player
|
||||
@@ -64,6 +67,7 @@ overriding or changing existing property editors.
|
||||
# In this example we'll support all objects, so:
|
||||
return true
|
||||
|
||||
|
||||
func parse_property(object, type, path, hint, hint_text, usage):
|
||||
# We will handle properties of type integer.
|
||||
if type == TYPE_INT:
|
||||
@@ -91,9 +95,11 @@ the inspector.
|
||||
extends EditorProperty
|
||||
class_name MyIntEditor
|
||||
|
||||
|
||||
var updating = false
|
||||
var spin = EditorSpinSlider.new()
|
||||
|
||||
|
||||
func _init():
|
||||
# We'll add an EditorSpinSlider control, which is the same that the
|
||||
# inspector already uses for integer and float edition.
|
||||
@@ -108,11 +114,13 @@ the inspector.
|
||||
spin.set_max(1000)
|
||||
spin.connect("value_changed", self, "_spin_changed")
|
||||
|
||||
|
||||
func _spin_changed(value):
|
||||
if (updating):
|
||||
return
|
||||
emit_changed(get_edited_property(), value)
|
||||
|
||||
|
||||
func update_property():
|
||||
var new_value = get_edited_object()[get_edited_property()]
|
||||
updating = true
|
||||
|
||||
Reference in New Issue
Block a user