Dharengo / Spriter2UnityDX

Converts Spriter .scml files to Unity prefabs
155 stars 41 forks source link

TextureController's sprites using SCML #5

Closed AlexandreRousseau36 closed 5 years ago

AlexandreRousseau36 commented 8 years ago

Hope I didn't do anything wrong

Dharengo commented 8 years ago

Alright, the code itself looks good, I guess. It works very good, very compact as well.

I wasn't sure about the XmlReader at first but it's slightly more efficient than deserializing the whole thing.

There's still some questions I have though.

All the extra white spaces and new lines, did you add those all yourself or is that an autoformatter thing?

Why did you change the default path for the settings asset? I'm not sure what you achieve by this.

Although I'll be honest, I really should figure out a method to change the settings without having to have a physical asset in the project. Maybe that will fix the whole pathing issue once and for all. :P

One of the things I have a problem with is the fix for the problem you are fixing. From what I understand, for some strange reason your array indexes are misaligned. So you choose to use the folder ids for the images as the index instead. This brings up a whole bunch of issues if the user should choose not to neatly arrange their images by folder, or simply have a different folder structure that makes more sense to them. All in all, it's sort of a flimsy "quick fix" that only works in very specific circumstances. It also is more of a workaround than a fix.

That is one thing I don't think I can add to the main build. I'd rather just actually fix the problem rather than use a situational workaround.

I thought at first it might be something worth including, but in the end it seems I'd rather not. You can use it yourself and recommend it to other people though. Just do provide a disclaimer that it only works when their folder structure matches yours.

AlexandreRousseau36 commented 8 years ago

All the extra white spaces and new lines, did you add those all yourself or is that an autoformatter thing? I am using auto format with MonoDevelop. That's an autoformatter thing.

Why did you change the default path for the settings asset? I just changed the path cause I don't want spriter2Unity to be in my Assets folder. I put it in my library folder with all the other libraries.

The fix itself. I think most of people will import their character once and make it a prefab with all their scripts and all. Then they'll change animation in this prefab's animator.

There are no strange problem for those indexes to misaligned. I'm more than amazed that nobody encountered that problem sooner.

That's because you create your indexes by going through every animation. So imagine two examples: I have two animations (Run & Walk) and I don't change my prefab every time I import. Cause I don't want to transfer my scripts and collider for example. I have a spriteRendererFeet with two sprites for my TextureController with [0:FeetRun,1:FeetWalk] when I import everything for the first time

Case 1 : I import only the animation I changed : Importing only Walk You're gonna create a new prefab with TextureController with [0: FeetWalk] and displayedSprite = 0 in your walk animation. If you put that animation in your other animator's prefab: You're gonna get FeetRun in your walk animation

Case 2: I import all my animation and use my prefab. This worked for me for a long time. But if a decide to have a crouch animation with crouchFeet in it. Spriter won't put your animation at the end of the scml cause it's using the order in the animations panel and the user can change this order everytime.

So If I put crouch at the beginning of my list in spriter, your algorithm will give you a result like this: TextureController with [0:FeetCrouch,1:FeetRun,3:FeetWalk].

Assuming you put those animations in your other prefab. All displayedSprite will be wrong. Even going out of range in TextureController.

That's why I decided to use SCML ids.

I'm not sure I see what the issue is with my fix. If they have all their sprites in only one folder, TextureController will be unnecessary big. But it should work too. They can't have more than 1 depths of folders for their sprites cause it will cause import to not work properly (The first bug I've encountered when using spriter2Unity). Maybe that's the pathing issue you're talking about. I also believe spriter2Unity might not work if they put all their sprites directly with the SCML with no folder.

I asked myself the folder issues too and I don't think you really have a choice here. Looks like It's 1 depth of folder or nothing.

If you really don't want my fix, I'll provide a disclaimer like you ask. At least it worked for me :) So I didn't do it for nothing.