After upgrading to Editor version 1.4, besides updating the engine version in the editor's Project Settings, please note the following changes to the 1.4 Spine API:
We no longer recommend creating Spine animations using the method: adding the SpineAnimationRenderer
component via addComponent
+ setting the resource using set SpineResource
.
In version 1.4, we introduced an instantiation method instantiate
for SpineResource. The instantiate
method returns a Spine animation entity that uses the resource, making the creation process much faster and more convenient.
defaultState
has been renamed to defaultConfig
. This parameter represents the default configuration of the Spine animation. The renamed parameter makes its purpose clearer.
The scale
configuration for default states has been removed. Previously, the scale
parameter was used to handle the pixel ratio of Spine animations to keep their size consistent with other objects in the engine. In version 1.4, Spine animations no longer require setting a default scale to correct their size. We recommend adjusting the Spine animation scale by modifying the entity's scale
parameter.
A new premultipliedAlpha
parameter has been added in version 1.4 for enabling premultiplied alpha rendering. When exporting animations from the Spine Editor, if premultiplication is checked during texture packing, enable the premultipliedAlpha
option.
Here are some tips to optimize the performance of Spine animations:
Export skeletons in binary file format (.skel), which results in smaller file sizes and faster loading.
Minimize the number of atlas pages by packing attachments into as few atlas pages as possible and grouping attachments in the atlas according to the draw order to avoid unnecessary material switches. Refer to Spine Texture Packer: Folder Structure for details on how to arrange atlas regions in your Spine atlas.
Avoid excessive use of clipping. Spine implements clipping by dynamically cutting triangles, which is very resource-intensive.
Minimize the use of atlas page textures. When exporting, aim to keep the number of texture pages as low as possible.
Try to use a single atlas texture for multiple skeletons. For example, add multiple skeletons in the same Spine project and select a single atlas during export. This way, multiple skeletons will share the same atlas texture.
If you have any questions about Spine, feel free to create an issue in the @galacean/engine-spine repository.