2019-10-22 16:56:22 +02:00
# Texture Packer for the Godot Engine
2019-10-20 21:19:00 +02:00
2019-10-22 16:56:22 +02:00
This is a texture packer engine module, for the Godot Engine.
2019-10-28 01:28:37 +01:00
It can create texture atlases for you even in the running game.
It uses the legacy version of [rectpack2D ](https://github.com/TeamHypersomnia/rectpack2D/tree/legacy )
2019-10-22 16:56:22 +02:00
2019-10-22 19:47:02 +02:00
It *should* work on all platforms.
2019-10-22 16:56:22 +02:00
# Building
1. Get the source code for the Godot Engine.
2019-10-22 19:32:33 +02:00
```
git clone https://github.com/godotengine/godot.git godot
```
2019-10-22 19:33:01 +02:00
2. Go into Godot's modules directory.
2019-10-22 16:56:22 +02:00
2019-10-22 19:27:31 +02:00
```
2019-10-22 19:32:33 +02:00
cd ./godot/modules/
2019-10-22 19:27:31 +02:00
```
2019-10-22 16:56:22 +02:00
2019-10-22 19:33:01 +02:00
3. Clone this repository
2019-10-22 16:56:22 +02:00
2019-10-22 19:27:31 +02:00
```
2019-10-22 16:56:22 +02:00
git clone https://github.com/Relintai/texture_packer texture_packer
2019-10-22 19:27:31 +02:00
```
2019-10-22 16:56:22 +02:00
2019-10-22 19:27:31 +02:00
4. Build Godot. [Tutorial ](https://docs.godotengine.org/en/latest/development/compiling/index.html )
2019-10-22 16:56:22 +02:00
# Features and Usage
## TexturePacker
2019-10-22 19:27:31 +02:00
This is the class that can merge textures. Add every texture you want into it using it's API (add_texture()), and then call merge().
add_texture() will return an AtlasTexture, this is the texture you want to use in your classes. It is immediately usable, it will just contain the original texture. Calling merge() will change it, to point to the new (merged) texture.
2019-10-22 16:56:22 +02:00
Supports filters, custom background color, margins.
2019-10-22 20:01:09 +02:00
### The keep_original_atlases option:
2019-10-22 16:56:22 +02:00
2019-10-28 01:28:37 +01:00
If you set this to true, and then add AtlasTextures, TexturePacker will change these ones (the ones you actually added)
2019-10-22 19:27:31 +02:00
after the bake.
2019-10-22 20:11:43 +02:00
2019-10-22 20:12:43 +02:00
You can use this to bake gui textures together, without changing the resources everywhere at runtime.
2019-10-22 20:11:43 +02:00
Think of rpgs, when you have a huge number of potential icons that the player can put on his or her actionbars.
2019-10-28 01:28:37 +01:00
You can take look at Tales of Maj'Eyal or pretty much every actually complex MMORPGs as an example.
2019-10-22 16:56:22 +02:00
2019-10-22 20:11:43 +02:00
Note: Doing something like this in only recommended, if you can't pre-make the atlases (or it's really unfeasible), you are better off
making the atlases yourself during development.
2019-10-22 16:56:22 +02:00
## TextureMerger
A Node that can bake textures for you. It uses TexturePacker internally.
2019-10-22 19:27:31 +02:00
It has an exposed Array, so you can assign textures to it in the editor.
2019-10-22 16:56:22 +02:00
## PackerImageResource
2019-10-22 19:27:31 +02:00
This is a simple Texture, which just contains an imported Image. It has no logic for drawing.
2019-10-22 16:56:22 +02:00
2019-10-22 19:27:31 +02:00
Useful for textures you only need for baking, as this class will not register it's data into the VisualServer.
2019-10-22 16:56:22 +02:00
2019-10-22 19:27:31 +02:00
The module also contains an editor plugin which can import textures as `PackerImageResource` Resource.
2019-10-22 16:56:22 +02:00
To access it, click on a texture, switch to the import tab, and in the "Import As" Dropdown, select "Packer Image Recource".