Jump to content

esDotDev

Members
  • Posts

    45
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by esDotDev

  1. That could be related to our issue, everytime we change an scml, and the prefab is regenerated, SpriterDotNet throws errors. Closing Unity and restarting fixes it. None of our animations use bones.
  2. Awesome thanks, we would really appreciate that! Also, for what it's worth, we're not using any of the advanced featured of Spriter, no MetaData, Sounds, Tags, Events etc, so I was able to get rid of half the garbage by just ignoring calls to GetMetaData completely. Might be cool if the plugin was smart enough to know, hey you aren't using sounds, you aren't using events, etc, and maybe run in a more optimized state? Just a thought. Cheers,
  3. Also, worth mentioning that Dengar's plugin, which converts the SCML to a UnityAnimation, generates absolutely no garbage, no matter how many instances exist in the scene. We switched to DotNet, because it seems better supported and seemed more future-proof solution, but it's really a bummer to see how much memory it's chewing through.
  4. Well it is quite worrying, as with 20 units in the scene, I'm seeing GC times of 8ms on a powerful PC, occuring every 3 seconds. This game will eventually run on PS4 / Vita which have much much weaker CPU's. So, I can't say I have performance issues right now on this PC, but certainly will once they game grows in complexity and runs on weaker machines. And considering I've put a ton of work into the game to remove as much garbage as possible, including object pooling, and optimizing loops and co-routines, it's frustrating to have this massive memory consumption wasting all my hard work. I agree, in general, premature optimization can be a waste, but the code inside this plugin is _extremely_ hot code, it could easily run several thousand times per second at 60fps with many units in the world, so I'd argue that optimizing this inner loop so it doesn't generate much garbage, is not pre-mature, it's a fundamental requirement. Tomorrow I'll try and I get this running on PSVita, and will be able to tell you for sure if we're seeing performance issues, but with 8ms collection time on PC, I'm pretty sure we will. I've looked at the code, and as you say, most of if it instantiation of Dictionaries, which I'm not really sure how to get around at the moment. I think you might have a much better idea on how you could possible cache/pool/reuse these frame objects, so they don't need to be constantly re-created. Another thing I noticed, there's pretty liberal use of for-each loops which (regrettably) are known in Unity to generate garbage because it uses an .NET old compiler.
  5. Testing this in Unity seems to be creating quite a bit of Garbage to be collected. I'd post this in the Unity thread, but any fixes will have to be done on the main lib. It looks like each Spriter instance is generating about 5kb of garbage each frame. You can see from the profiler, ApplySpriteTransform is creating about .5kb, and then GetFrameData and GetFrameMetaData() are creating about 2.1kb each. I'm looking into it now, and will post back if I'm able to reduce it.
  6. Also, one other small but pretty annoying issue, is that whenever the prefab is regenerated, the positioning and scaling info is reset anywhere in the project the prefab is references. I have an archer Game Object, with a nested Spriter Animation, positioned where I'd like him to be within his parent: Archer --> ArcherSpriter (x = -1.78, y=3.16, scaleX: .85, scaleY: .85) Everytime the SCML is reimported, the ArcherSpriter instance resets positioning to 0,0 and scale to 1,1. Any way those could be retained? I also added a bit of functionality to UnitySpriterAnimator, in order to allow me to swap sprites at any time, in any animation: Dictionary<string, Sprite> swappedSprites = new Dictionary<string, Sprite>(); public void UnswapSprite(string name) { if (swappedSprites.ContainsKey(name)) { swappedSprites.Remove(name); } } public void SwapSprite(string name, Sprite sprite) { swappedSprites[name] = sprite; } Sprite GetSprite(Sprite sprite) { if (swappedSprites.ContainsKey(sprite.name)) { return swappedSprites[sprite.name]; } return sprite; } protected override void ApplySpriteTransform(Sprite sprite, SpriterObject info) { .... renderer.sprite = GetSprite(sprite); .... } This allows me to do fun stuff, like make my character blink randomly, regardless of their animation state. spriterAnimator.SwapSprite("eyesOpen", eyesClosedSprite);//Close eyes //Wait 100ms spriterAnimator.UnswapSprite("eyesOpen");//Open Eyes Or, swap his hands randomly, to make it appear as if he's stumming a guitar, regardless of the current animation he's in. (our character can strum guitar while running, standing still, getting hit, etc, and we didn't want to have to bake that in to the animations themselves) //Inside a Coroutine while(true){ spriterAnimator.SwapSprite("chordHand_0", GetRandomChordSprite()); spriterAnimator.SwapSprite("strumHand_0", GetRandomStrumSprite()); yield return WaitForSeconds(tempo); } Doing it this way lets us change the tempo of the strumming to match the music, rather than having it tied to the animation speed. This also allows you an easy way to do character maps, without having to define them in Spriter.
  7. Sure: https://www.dropbox.com/s/k40jec9wb3flxz7/archer.zip?dl=0
  8. I'm getting errors trying to update an SCML file that has already been imported. NullReferenceException: Object reference not set to an instance of an object SpriterDotNet.SpriterProcessor.GetObjectInfo (SpriterDotNet.SpriterAnimation animation, System.String name) SpriterDotNet.SpriterProcessor.AddVariableAndTagData (SpriterDotNet.SpriterAnimation animation, Single targetTime, SpriterDotNet.FrameMetadata metadata) SpriterDotNet.SpriterProcessor.GetFrameMetadata (SpriterDotNet.SpriterAnimation animation, Single targetTime, Single deltaTime, SpriterDotNet.SpriterSpatial parentInfo) SpriterDotNet.SpriterAnimator`2[TSprite,TSound].Animate (Single deltaTime) Steps to reproduce: Import the attached SCML file. Allow SpriterDotNet to create Prefab "ArcherSCML" Open SCML File, rename the entity to "ArcherSCML1", and save. Allow SpriterDotNet to create a new prefab "ArcherSCML1" It should now throw the above error anytime you try and drag either ArcherSCML or ArcherSCML1 into the scene. archer.zip
  9. What's strange about this, at least with my example, is that the keyframe's are all perfect, everything looks absolutely correct within Unity, so the script doesn't appear to have any errors with how it's creating keyframes and placing objects. But there's just this crazy easing going, between the keys, and I can't pinpoint the source of it.
  10. Not sure how much use this will have for the current Spriter2Unity plugin, as what we do now is to churn through the SCML and turn it into a Unity Anim, once they are created they are subject to all limitations and features of standard Unity animations. This would be a much more flexible runtime for SCML files. It's cool, but an entirely different direction than the current plugin. Hopefully someone will step up to the plate to create one.
  11. The DX version is the latest, and it worked fine for our animations, you shouldn't need to do anything special to link the Sprites.
  12. Yep I got it. It just means I need to drag in references to the sprites, into the Unity Editor, in order to perform swapping, rather than just being able to use strings. But that's fine, no big deal. It's probably actually preferable once I get used to it :) A name change would be good, to avoid confusion, and free up that component name if we want to make a true SpriteSwapper in the future. In terms of the bug... it shouldn't be related to registration points. I've fixed them all for this specific SCML file, and they don't change mid-animation or anything, and the other 3 solos all work fine. Lemme know if you'd like a sample of the File. Here's another video showing what it should look like in Spriter, and comparing to Unity: http://screencast.com/t/9VpQwv4gyb
  13. I think I may have found a bug of some sort. 1 of our 11 animations is not playing correctly. For some reason, it's adding extra animations, which are not defined in the keyframes, or present in Spriter. You can see a video here: http://screencast.com/t/t1s7hYmaC Any idea? Looks like it's using some weird non-linear ease.
  14. Woah, didn't expect there to really be a workaround for this, sweet! Doesn't seem to be working properly though, when I combine sprites, they dissapear from the animation. Re-opening the file doesn't seem to help. Looking at the SCML, shows the following: [uPDATE] It seems that simply renaming all the objects, in the Objects Pane works fine. If I just go through every single object_xxx and replace with the proper name, close and restart, it works like a charm.
  15. Hmmm, my thoughts are that the Swapper could easily be injected with the references to the sprites that we need to work with, and would be so simple to implement there, that it kinda makes sense for it to just be the one to handle it. I think the purpose of the tool is two-fold. Bring the animation into Unity, yes, but then also provide an API surface to manipulate the animations at runtime. One of the biggest benefits to this type of animation is the ability to swap different hats, armor, weapons etc on the same animation rig. I'm not even sure how I would implement that externally... since all the sprites are packed into a texture atlas by unity, how do I even get a reference via Script? Maybe I'm missing something... I've only ever used 2dToolkit before, and am still a bit of a Unity noob when it comes to low level stuff. I could drag and drop references to each sprite in the editor, but that could be a bit tedious when I just want to swap by string_name. [Edit] Just playing around with swapping the sprites directly, from a parent script that has references to the individual sprites, and it actually works quite well, so maybe you're right and it's fine as is.
  16. The ideal approach I think, would just be to loosen the restrictions, and allow SpriteSwapper to swap to any of the images included in the SCML file. Just inject a List<Sprite> of all sprites into each instance of SpriteSwapper, and then we could modify the Swap() fxns to look there. Then, we can manually add a SpriteSwapper to any object, and swap arbitrary sprites by name. This would be quite a bit more flexible, and should be relatively easy? Ideally the system would be smart enough to retain a custom SpriteSwapper script if it was placed on an Object manually, but if not that would be Ok. We could always attach the SpriteSwapper(s) via scripting in the parent object. Understood. I don't mind trying to step in and contribute. I'll see if I can get the allSprites thing figured out and send another pull request.
  17. Sure, to explain a bit more. We have a dude, he holds a guitar in every animation. Idle, Walk, Run, Solo etc: We don't use Spriter to swap his hands, as that would be very time consuming, and not allow us to alter the tempo. Instead we do it in script. Using the SpriteSwapper we randomly swap hands a few times a second, totally independent of the animation he's in. This way he can walk, run, solo etc, all while strumming his guitar, saving us a lot of time. We can also speed up or slow down his 'strumming speed' depending on the song being played, without having to speed up the entire animation. Now the issue is, because we never swap his ChordHand in Spriter, SpriteSwapper is never assigned when the Prefab is created. In order to make SpriteSwapper appear, with the valid sprites, I need to create a dummy animation, with 5 keyframes, one for each hand sprite I want to swap through code.
  18. Just to clarify this, all you need to do to enable batching, is select the sprites within the folder, and assign them a "Packing Tag" property, this will cause them to be batched together in a single draw call.
  19. We're trying to port our animations over to Unity, and I think we're running into some bugs as a result of old version of Spriter. The problem is only present in some of our very earliest animations. Under the Z-Index column, all the pieces are named "object_00x" to "object_2xx", and each animation has unqiue names. So, our main character has over 200 of these objects defined in his SCML file. For example: etc... This breaks the Sprite2Unity importer and Sprite Swapping functionality, as it creates a new child for every single unique name in the z-index column. If I try and rename the animations, and make them look like this: Spriter won't allow me to do it. I can fix one animation, but when fixing subsequent anims, Sprite auto renames "head" to "head_000", or "torso" to "torso_000". Next animation, will force me to name it "Head_002", and etc. It simply won't allow me to fix these names within the Editor. Is there any way you can think of to fix these old SCML files? I can't hand edit it, it's close to 11,000 lines...
  20. Just spent some time playing with your SpriteSwapper, and I've extended it a bit already. Rather than swap slots by index, which can be confusing, and prone to error, I've added the ability to swap by name. So now we can do stuff like this: //Blink!swapper.Swap("head", "head_blink");yield return new WaitForSeconds(.1f);swapper.Unswap("head");//Randomly strum guitarwhile(true){ swapper.Swap("strum_hand_0", "strum_hand_" + Random.Range(0, 5)); yield return new WaitForSeconds(.2f);} I'll commit this to Git and you can choose whether to accept :) The one pain point I've found so far, is the need to add each swapped image inside the timeline in order to have it added to SpriteSwapper. Then when swapping, I end up fighting these timeline swaps that I don't really want.... It would be nice if SpriteSwapper could be added manually within Unity, and you could swap to any of the sprites in the entire animation. Best workaround right now, is to just create a dummy animation, and add a bunch of keyframes, for each image you want to swap. Not a horrible workflow, but feels a bit hacky.
  21. We don't change it while animating, we have a "Key" animation, where we setup all the sprites, and adjust their pivot points. Then we copy that anim as the starting point for all other anims. I'd argue this is core functionality of the plugin, and hopefully would be higher priority than minor issues that do not cause broken animations to be created. When we built these animations (2013-2014), I don't think Spriter had the ability to edit the Pivot Points of the images themselves, of if it did, we weren't aware. The only way we knew how to do it, was setup a timeline, adjust pivot points there, and duplicate. I suppose I could hand-edit the SCML files, and move the values into the File<> element, but we have about 30 of them, so it's quite time consuming. Here's a link to the Ratcoon SCML if you'd like it for testing. It's very simple, only 3 animations (key, idle, run) and 7 images: https://www.dropbox.com/s/05zv92qu9xo90qh/ratcoon.zip?dl=0
  22. Ya, what's happening, is it's using the Global pivot_x and pivot_y setting for each sprite: settings.spritePivot = new Vector2 (file.pivot_x, file.pivot_y); But it's ignoring the pivot_x and pivot_y overrides that are assigned to each Timeline<> entry. Here you can see an example of our Racoon character, the default pivot for his parts are x:0,y:1, but each part has a custom pivot defined in each frame (it doesn't typically change): http://gyazo.com/725bb6e8e6b1dbd979d3129dce5532e1 This results in all sprites being Top-Left aligned, and ignoring the correct Pivot Points defined in Spriter. I'm not even sure why pivot_x and pivot_y are defined on the File<> element, since there doesn't seem to be any way you can change it from the default.. Maybe to support exporting from external image editors?
  23. Origin point is the anchor point of your image, all positions are relative to it, and it's the rotational center of your image. By default, in Unity, all images are center-aligned, but in Spriter, this is customizable. You see in the Torso of brad, his origin point is down by his belt buckle. When imported into Unity, this is not taken into account, and he's aligned as if his origin point was in the middle of his chest. That's only my guess to what is going on... for some reason none of them will import properly. Digging into it a bit more... it seems to have to do with setting the 'Pivot' of each Sprite to x:0, y:1, which is causing all the sprites to have incorrect pivot/origin points.
  24. Looks like the importer is not currently respecting Origin points. After importing it looks like this: Rather than this in Spriter: Tried this with 3 different animations, and same result for all.
×
×
  • Create New...