• Editor
  • Relative paths for Images

Hey!
Is there any way of making .spine files store the path to there Images folder relative to itself instead of an absolute path?

I work half on my laptop and half my PC at home and my project is stored on a different drive on both.
This means when I open a Spine file I'm constantly having to change the Images path from C:// to D:// and back again. If it was store relatively then it would work fine 🙂

If it's not currently possible this a feature that could get added? I think its a pretty common problem and can't think of a downside..

Related Discussions
...

It does that already, though it is limited to 3 parents (ie ../../../xyz). The limit is to prevent a path like ../../../../../../../../../xyz, since if you go back far enough you can make any path relative for a given drive.

The problem with your setup is that your paths are on different drives. There can't be a drive in a relative path, like ../../D:/xyz. We could do something like if the relative and absolute paths fail, we could change the drive to that of the project file and try again. This may be weird though, since it would allow Z:/images to work even when Z:/ doesn't exist by finding C:/images when your project file is on C:/. Because of that, I'm not sure it's a great idea? There may be such a thing as too much magicke!

4일 후

Hey! Ah, nice I didn't realise that!

I guess what would be really nice however is when you click browse and find your image folder it then converts that path to being realitve (if possible), rather than having to manually typing it out, only a thought though!

Yeah sorry although my projects are on different drives on my two computers, the images folder is always on the same drive as the spine animations (ie on PC everythiong is in [url=C://MyGameProject]C://MyGameProject[/url] and another is in [url=D://MyGameProject]D://MyGameProject[/url]). Having realitve paths referencing different drives does indeed sound crazy!

ToddRivers wrote

I guess what would be really nice however is when you click browse and find your image folder it then converts that path to being realitve (if possible), rather than having to manually typing it out, only a thought though!

It should do this already. Whether typed or picked from the file dialog, it should be converted to a relative path as long as the relative path doesn't have more than 3 parent folders (../../..).

Ah! Doh! I miscounted and my paths have four parent folders doh! Haha typical 😛

I can understand wanting to limit path length but could you not instead of having the 3 parent folder limit, check for it being on the same drive instead? I've tried to restructure my project a bit but more flexibility is always welcome 🙂
(I realise I've probably just got a unusual project structure!)

If you have a small server that is always on the network, you could save your projects and images on that instead. Then one both computers mount the network folder with the same drive name. May not be an option for you, but worth a shot.

6년 후

Im aware that this i a rather old discussion but it is still a problem for us every now and the.
My question is why this limit to 3 parents (ie ../../../xyz). We have a game with .spine needing 4 parents in the relative path.

Should we reorganize assets to use less subfolders or is there some other solution?

Spine processes the images path and makes it relative if it is within 3 parent folders. This limit of 3 parent folders was chosen somewhat arbitrarily, but we do need a limit so you can use an absolute path. Without a limit you'd end up with something like ../../../../../../and/then/the/path if you chose a folder very far away from your project folder.

Spine does this path mangling automatically, without a way to preserve the path as entered by the user. Usually this isn't a problem, you are the first to mention needing a relative path with more than 3 parent folders. Unfortunately we don't have a workaround at this time, so organizing your folders to avoid needing 3 parent folders would be a good solution.

Another option could be to use symbolic links. These are common an Linux and Mac, but they can also work on Windows. For example, each of your Spine project folders could have a symlink called images that points to some other path (relative or absolute). It appears to Spine like a normal folder.

    Nate Thanks for the quick reply. I'll include a check for more than 3 parents in the relative path in our build process.

    17일 후

    Nate Hey Nate! Oddly enough I have the exact same situation as mbi, haha. Our spine project is on Dropbox, and we have a very custom folder layout so that we can texture pack a bunch of spine project's images into a single texture atlas. We would need 4 levels of parent folders for the relative path 😆

    I've got two questions:

    1) I see your response about using symbolic links - seems like a decent option so I'll definitely look into that. I was curious though if there is any way to use an Environment Variable as part of the path? We use Environment Variables a lot with our .bat files for exporting spine projects and texture packing so that would work nicely with our workflow if that was possible.

    2) Another option might be that if I were to manually type in the relative path (aka "../../../../../../and/then/the/path" lol) for it to keep what I typed and not automatically replace it with the absolute path if its more than 3 parent folders up. Any thoughts on that?

    Either way, sounds like the option with the Symbolic Link will be a good option for future setups.

    Seems like Dropbox supports symbolic links:
    https://help.dropbox.com/sync/symlinks

    Environment variables are an interesting idea. We'll add support for that to our list, cheers!

    Sorry, there is no way to have Spine not "relativize" the images path, except if you provide an absolute path, which of course defeats the purpose.

    16일 후

    In 4.1.22 we've added a --relative-parent-max CLI parameter. The default is 3 and this allows you to set it higher (or lower, I suppose). Setting it high, eg to 99, will make all paths relative, except the root of a drive is always absolute (eg C:\).