Internal Extensions
Internal extensions are extensions that are not .pck
files, but actual code (arranged in the same format as you would an extension) in res://src/Extensions/
.
The concept of internal extensions was origally targeted towards potentially making pixelorama more modular by grouping some of it's features into smaller extensions, but it can also be used in developing of extensions by users.
Comparing the two methods
Internal Extensions | Standard way (as separate project) |
---|---|
Both ways are easily interchangeable | Both ways are easily interchangeable |
During development you don't have to export a pck, every time you need to debug the extension | To debug you'd have to re-export your extension which is time consuming |
Both Pixelorama's source code and creating an Extension project is required (The Extension project is required for when you release your extension) | Creating the Extension project is required but Pixelorama's source code is optional |
You can extend pixelorama's classes (like BaseTool) | You can still extend classes, but Godot's code editor will complain (it's perfectly fine but it's not very pleasing to the eye) |
Making an Extension, internal
To ensure your work isn't accidentally lost, it is highly recommended that you use version control (e.g Git) in your extension project and in pixelorama's source.
- First, make an extension project by following this tutorial (from here, it will now be referred to as your project).
- Get and unzip the source code of pixelorama that you intend to use for your extension.
- Create an
Extensions
folder (case sensitive) in the pixelorama's source code in thesrc
folder. - From your project, copy (not cut/move) the contents from
src/Extensions
folder to thesrc/Extensions
folder in pixelorama (created in step 3). - Navigate to the
src/Extensions/(extension name)/extension.json
file and copy the value of thename
key. Then opensrc/HandleExtensions.gd
file in pixelorama's source and find the_add_internal_extensions()
method. Modify and save it as follows:func _add_internal_extensions() -> void:
_load_extension("ExtensionName", true) # Add this line, and replace `ExtensionName` with the value of your `name` key.
Now the extension has become internal. From here you can continue to code in the Extensions/<your extension>
folder of pixelorama (just don't create any files in outside your extension folder).
Exporting your extension.
When you are done making your extension and are ready to release and distribute your extension you have to convert your internal extension back to a regular extension.
- Remove/comment the line that was added to
src/HandleExtensions.gd
(In step 5 of Making an Extension, internal) - From pixelorama, copy (not cut/move) your extension folder from
src/Extensions
, back to thesrc/Extensions
folder of your project (replacing existing files). - Export your project by following this tutorial.