- Modifié
Unity3d importer [beta]
- Modifié
I've made first beta version of spine exporter.
It's not a run time, and just build unity objects (animator, animation, spritesheet + skin controller script)
It does not support all spine features.
Currently it doesn't support following things:
-
regionsequence
-
color animation
-
mesh animation
-
Export several json files with shared atlas (spine project with several skeletons)
partial support
-
smooth animation (Bezier curves in unity is a little bitt different, but in most cases it should work as expected)
features hass been done by 3d people:
abraksil
-
events
-
draworder
it's available here https://github.com/nicloay/unity-spine- ... r/releases
A little bit later i'll add some type of documentation. but it's easy. just right click on json file and choose "spine build prefab"
here is a video about how it works right now. I've been tried to record it 3 times and faced different bugs =). good reason to fix that.
Loading Image
(images are pointed to youtube)
Just watched your video here:
http://www.youtube.com/watch?v=XOEBjAdJxUk
Looks quite interesting! I'll have to give it a try when I get home. 
CYBR Labs a écritJust watched your video here:
http://www.youtube.com/watch?v=XOEBjAdJxUk
Do you have internal yotube events =)? Yesterday I was waiting more than 1 hour while youtube process that video, run out of patience and went to sleep and didn't post it here. Now I've added it at first post.
Looks very helpful for those struggling with json and Unity integration. I'm sure once support for mesh goes in, more would be interested in this.
Definitely going to keep an eye on this tool you've created. :yes:
today i'm working on new cool features. Just done AvatarMask

It used in animator.E.g. when you want to combine several animation or don't want to animate one bone of character.
This is quite neat! 
Looks cool 
This Is awesome nicloay 
Just brought a spine project into unity 
hope you can get the smooth animation curves to work.
Awesome thanks
Wow this looks great! Quick question though, is it required for you to move your Spine project files into your Unity project directory like you did in that video or can those exist outside of the Unity project as long as you still export from Spine into Unity's asset folder?
No. You don't need project files. Jus move 3 export files. Json export, atlas.png, atlas.atlas metadata.
Excellent, thanks. I can't wait to play around with this.
So I'm apparently hitting an unsupported attachment type already. Is this because I'm using meshes in Spine?
Attachment type not supported yiet FIX MEEE
UnityEngine.Debug:LogWarning(Object)
UnitySpineImporter.SpineUtil:addAllAttahcmentsSlots(SpineData, SpritesByName, Dictionary`2, Int32, List`1&, AttachmentGOByNameBySlot&) (at Assets/UnitySpineImporter/Scripts/Editor/Util/SpineUtil.cs:344)
UnitySpineImporter.SpineImporterWizard:OnWizardCreate() (at Assets/UnitySpineImporter/Scripts/Editor/SpineImporterWizard.cs:64)
UnityEditor.HostView:OnGUI()
Which then throws:
NullReferenceException: Object reference not set to an instance of an object
UnitySpineImporter.Slot.hideAllAttachments () (at Assets/UnitySpineImporter/SharedScripts/Slot/Slot.cs:44)
UnitySpineImporter.Slot.showDefaultAttachment () (at Assets/UnitySpineImporter/SharedScripts/Slot/Slot.cs:56)
UnitySpineImporter.SkinController.showDefaulSlots () (at Assets/UnitySpineImporter/SharedScripts/SkinController.cs:57)
UnitySpineImporter.SpineImporterWizard.OnWizardCreate () (at Assets/UnitySpineImporter/Scripts/Editor/SpineImporterWizard.cs:74)as i see regionsequence is not implemented yiet, because of that you're getting this error.
Just region(image) and boundingbox(collider) supported right now.
new version v0.3 released.
New Features:
Update existing animation instead of creation new one's.
Now if you will reimport spine data, you can choose, recreate new animation and animators, or just replace existing animation keyframesSmooth Curves, partial support. (not all Bezier curves can be transferred in to the unity, but it's better than nothing =), or linear animation)
BugFix:
rotation animation, full round fix
take latest version here
This is amazing! thank you very much!
karlozalb a écritThis is amazing! thank you very much!
thanks.
I've just recorded video (also included it in the first message) http://www.youtube.com/watch?v=7MfUAelg9hQ here i show my project with animator. Hopes that it will answer the main Nate question - "why to use animator" =).
Hehe, love the Unity interface bugs.
My favorite is if I open a scene from a different project, a new Unity instance opens and the old one crashes. Crashes every time and has been since 4, if not earlier.
Thanks for the video, it is neat to see how the state machine stuff works. It's a strange way of creating the functionality for me, I am much more comfortable writing code to do it, but I can still appreciate it.
From what I can see, everything you did can be done with spine-unity. You can control the active animations, mix between animations when they are changed, modify the animation speed dynamically, apply an animation on only a subset of bones, apply multiple animations at the same time, etc.
Is it possible to use the state machine / flow chart stuff to trigger code? If so, you could use it to set animations using spine-unity.
I don't (yet
) see a big difference between using a prefab and using spine-unity. Have you tested performance difference on mobile devices? I have a feeling that spine-unity may perform a bit better.
Hi Nate. First of all sorry for my english, sometimes i'm telling not the same what I think in russian =).
I don't want to blame unity-runtimes, and i more than sure that native runtime should work faster, and even if in any cases mecanim will be faster you will find the way how to optimise it.
Main reason why i made this package, because it's should be easier for artists to work with animator, than to go in to code and make some changes there.
here is a code which I made for that model in the second video
https://gist.github.com/nicloay/9002437
and here is default state machine
Loading Image
it support following features
walk
run
run/walks depends on speed
in air up
in air down (depends on velocity)
punch left
[combo] punch left, right
[combo] punch left, right, upper-cut
roll out
throw (from any state)
-
complex jump with
maybe something else.
Don't forget that if you want to adjust some transition, or blending animation, you don't need to go to code, you can do that in the editor using native features.
Now just tell how many things you need to do as a programmer if you first time opened unity and trying to make something similar with spine-runtime. Sorry, i've tried just import to spine-runtime, but didn't tried to make any controllers.
Nate a écriteverything you did can be done with spine-unity.
...
Have you tested performance difference on mobile devices?
as i told before, you're right, spine-runtime should be faster, but almost everything you need to do through the code.
Nate a écritIs it possible to use the state machine / flow chart stuff to trigger code? If so, you could use it to set animations using spine-unity.
No, i don't think so, in animator, you define state and provide animation for that state. But, from animation(which is native unity animation) you can. (more details here)
Sorry, i can't make performance test right now, and will be happy if someone will did.
upd1.
I forgot to tell that in video, but there is one more thing. Because of using native sprites, for each sprite unique mesh generated, which reduce number of empty pixels what is good for renderer and increase performance
Loading Image
Probably you can achieve the similar if you will define meshes for each sprite in unity.
Don't worry, your English is fine.
You dropped the F bomb at just the right time. 
There is defintely some benefit to doing things the way Unity users are used to, that's for sure. It's unfortunate if the flow chart stuff can't be used to control code, it seems like a missed opportunity for Unity. I wish I had time to dig into it. I will when I get a chance!
Honestly the way of making things work in Unity is awkward for me. I am sure how spine-unity is used can be made more friendly, even if the flow chart stuff can't be used. A spine-unity controller should be similar to how you had to write code for your controller. Once done it should be relatively easy to customize or reuse.
Spine can do meshes, though I haven't updated the Unity runtimes yet.
I'm not knocking your runtime, it is quite neat.
Probably the biggest advantages are that everything is a GameObject, so you can attach things without using BoneComponent, and that Unity users may already be used to using the Animation tools. It's good to have options!
Thanks for the update and video nicloay 
Glad to see continued work on this! :yes:
EDIT: Does image swapping work? I seem to have an issue with all the images moving off the body erratically.
Do you mean slot order animation? no currently it doesn't work
Yes, that is what I mean. I shall await for it to one day work. 
Is this project still in development? Hoping it isn't dead, going to give it a try tonight!
rxmarcus a écritIs this project still in development? Hoping it isn't dead, going to give it a try tonight!
I didn't work on this importer for the last month. But if you have any critical bugs, (not a feature like FFD) i'm ready to fix them.
Hi Nicloay,
Just found your Run time today and it looks really good i have run into a slight problem though. When i hit generate to make my Prefabs, i get this
SpineMultiatlasCreationException: provided file does not exists
UnitySpineImporter.SpineMultiatlas.deserializeFromFile (System.String multiatlasFilePath) (at Assets/UnitySpineImporter/Scripts/Editor/Model/Spine/Atlas/SpineMultialtas.cs:19)
UnitySpineImporter.SpineImporterWizard.OnWizardCreate () (at Assets/UnitySpineImporter/Scripts/Editor/SpineImporterWizard.cs:60)
UnityEngine.Debug:LogException(Exception)
UnitySpineImporter.SpineImporterWizard
nWizardCreate() (at Assets/UnitySpineImporter/Scripts/Editor/SpineImporterWizard.cs:82)
UnityEditor.HostView
nGUI()
Im following the tutorial exactly but im still getting this message?
any tips?
PaulMcG a écritHi Nicloay,
Just found your Run time today and it looks really good i have run into a slight problem though. When i hit generate to make my Prefabs, i get thisSpineMultiatlasCreationException: provided file does not exists
UnitySpineImporter.SpineMultiatlas.deserializeFromFile (System.String multiatlasFilePath) (at Assets/UnitySpineImporter/Scripts/Editor/Model/Spine/Atlas/SpineMultialtas.cs:19)
UnitySpineImporter.SpineImporterWizard.OnWizardCreate () (at Assets/UnitySpineImporter/Scripts/Editor/SpineImporterWizard.cs:60)
UnityEngine.Debug:LogException(Exception)
UnitySpineImporter.SpineImporterWizardnWizardCreate() (at Assets/UnitySpineImporter/Scripts/Editor/SpineImporterWizard.cs:82)
UnityEditor.HostViewnGUI()
Im following the tutorial exactly but im still getting this message?
any tips?
Hi PaulMcG,
Could you share xml and json files, and I will check why it doesn't work.
And please note that you don't need to rename spine generated files, xml,json and png.
Аs I remember xml and json should have the same names, like
AABB.json AABB.xml.
Also you can check your xxxx.atlas file, it hase a name of png file inside, like
Kevin.png
format: RGBA8888
filter: Linear,Linear
repeat: none
Leg_L/foot_l
...
which mean that Kevin.png should be located in the same folder.
This file can have several links to images, just searh by "format" keyword, and png file will be above that row.
Hi Nicloay,
Thanks for getting back to me so quickly, Files are attached.
Hope its something simpleskeleton.jsonskeleton.atlas.txt
PaulMcG a écritHi Nicloay,
Thanks for getting back to me so quickly, Files are attached.Hope its something simpleskeleton.jsonskeleton.atlas.txt
try to rename skeleton.atlas.txt to skeleton.atlas at first.
My importer take json name and trying to search atlas file with the same name and *.atlas extension. unlike of original spine runtime, this importer doesn't use input files and generate prefabs, so it's not needed to make assets with that data.
No that didn't help got the same Error.
Ive attached the Spite sheet below see if you get the same error i do
PaulMcG, i found several issues.
1 - atlas file has a new property, so the problem was to correct parse input data. [fixed, release it soon]
2 - Problem on unity side: it's not possible to add curve with one keyframe [working on it]
upd1: you can take latest version here (currently it's 0.3.1)
Don't forget to rename txt extension from .atlas file. Also you will see many errors because of your animation has just one frame, don't worry about them pose should be fine.
I asked about that on unity forum. If i will find how to fix that, I'll do that. problem is that this error comes from unity c++ side.
HI NicLoay,
Thanks for doing the changes so quickly, im getting half way but still not working 100 percent. I Have two walk cycles a forward and a backwards in my spine project, but only a single frame appears and no animation or animator files?
Im using spine version 1.8.35 profeshional and Unity3D 4.3.2f1 could their be a clash of versions?
I could email you my Spine project and you could see exactly what should be coming out the other side?
With Paul project found one more bug (no slot attachments gave an error)
fixed in v0.3.2 version
Hi nicloay,
Using your latest version, I'm getting the following:
NullReferenceException: Object reference not set to an instance of an object
UnitySpineImporter.SpineUtil.addAnimation (UnityEngine.GameObject rootGO, System.String rootDirectory, UnitySpineImporter.SpineData spineData, System.Collections.Generic.Dictionary`2 boneGOByName, UnitySpineImporter.AttachmentGOByNameBySlot attachmentGOByNameBySlot, Int32 pixelsPerUnit, ModelImporterAnimationType modelImporterAnimationType, Boolean updateResources) (at Assets/UnitySpineImporter/Scripts/Editor/Util/SpineUtil.cs:393)
UnitySpineImporter.SpineImporterWizard.OnWizardCreate () (at Assets/UnitySpineImporter/Scripts/Editor/SpineImporterWizard.cs:76)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.ScriptableWizard.OnGUI () (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/ScriptableWizard.cs:89)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/BuildAgent/work/d3d49558e4d408f4/Editor/Mono/GUI/DockArea.cs:231)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/BuildAgent/work/d3d49558e4d408f4/Editor/Mono/GUI/DockArea.cs:224)
UnityEditor.HostView.OnGUI () (at C:/BuildAgent/work/d3d49558e4d408f4/Editor/Mono/GUI/DockArea.cs:120)
It still creates the skeleton, but the heirarchy of bones on the skeleton appear to be in the wrong order. Any idea what I might be doing wrong? Running version 1.8.41 of Spine.
Thanks,
Marc
rxmarcus a écritHi nicloay,
Using your latest version, I'm getting the following:NullReferenceException: Object reference not set to an instance of an object
UnitySpineImporter.SpineUtil.addAnimation (UnityEngine.GameObject rootGO, System.String rootDirectory, UnitySpineImporter.SpineData spineData, System.Collections.Generic.Dictionary`2 boneGOByName, UnitySpineImporter.AttachmentGOByNameBySlot attachmentGOByNameBySlot, Int32 pixelsPerUnit, ModelImporterAnimationType modelImporterAnimationType, Boolean updateResources) (at Assets/UnitySpineImporter/Scripts/Editor/Util/SpineUtil.cs:393)
UnitySpineImporter.SpineImporterWizard.OnWizardCreate () (at Assets/UnitySpineImporter/Scripts/Editor/SpineImporterWizard.cs:76)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.ScriptableWizard.OnGUI () (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/ScriptableWizard.cs:89)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/BuildAgent/work/d3d49558e4d408f4/Editor/Mono/GUI/DockArea.cs:231)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/BuildAgent/work/d3d49558e4d408f4/Editor/Mono/GUI/DockArea.cs:224)
UnityEditor.HostView.OnGUI () (at C:/BuildAgent/work/d3d49558e4d408f4/Editor/Mono/GUI/DockArea.cs:120)It still creates the skeleton, but the heirarchy of bones on the skeleton appear to be in the wrong order. Any idea what I might be doing wrong? Running version 1.8.41 of Spine.
Thanks,
Marc
Hi Marc,
Could you show your .json and .atlas file.
Sure, sorry should have posted before, here you go.
Thanks for the quick fix. Yea that one doesn't have animations because I actually import him and create a ragdoll object with him to spawn during deaths in our game. =)
