maxgribov/Spine

image resource mismatch

liuyaping1 opened this issue · 7 comments

Thank you, this library I have been using very well recently. But there is a small suggestion in Skin.swift ,

 func texture(with name: String, from atlasName: String) -> SKTexture, 
let textureName = atlas.textureNames.first(where: { $0.contains(name) }) ,

sometimes If the resource name prefix is ​​the same, there will be a mismatch. I try to modify it to solve the problem:
let textureName = atlas.textureNames.first(where: { $0.contains(name.appending(".")) }).
Or do you have a better solution?

Please read careful this: https://github.com/maxgribov/Spine/wiki/Assets especially about namespaces. If you correctly place all your images as described in the instructions, everything will work without problems.

I am sorry ,What you said is right. I place my images use another way : In the actual project, I added a monster.atlas folder with my image files, then use like this:(I refer to here, https://developer.apple.com/documentation/spritekit/sktextureatlas
let atlas = SKTextureAtlas(named: "monster")
Could you add an api to support this usage?

In fact, what I ultimately want is a remote control of the spine animation, including json file and image resources,that is those assets might be procedurally generated or downloaded from the network, then create a Texture Atlas at Runtime.
I found this method and simply tested this program is feasible
init(dictionary:)
Unfortunately, spine does not support this usage.

I'm sorry, but I don't plan to support every single case that library users come up with. But you can always fork this repository and add any functionality you want. As for the work with cassettes, everything will remain as it is currently implemented.

OK,Got.
If I am modified my fork repository for supporting init(dictionary:) , need I submit a merge to master?

You can make PR

Actually Sceleton has constructor:

public init(_ model: SpineModel, _ atlases: [String : SKTextureAtlas]) {

so you can initialise it with dictionary of your custom texture atlases ... created for example at runtime...