Certainly! I'll look into Unity
Unity and C# runtimes, more videos
Hey guys, quick questions.
We are testing the Spine trial and wanted to check how the Unity runtime manage the assets in order to see if we can use it in our projects.
I downloaded the github code for Unity runtime but it appears to be missing the Spince.cs file or maybe a dll. The question is: do you send this files once we get the full version of spine to test it or am I missing something.
Thanks a lot and congratulations on Spine.
Thanks Arturo.
For the Unity runtime you need to copy the spine-csharp files into the Unity directory. Actually I'll just simplify things and commit it that way in github. Done! Grab it again from github and try again please. You should be able to try out the Unity runtime before purchasing Spine.
Hi Nate,
Thanks a lot for the quick response, now I get it.
We´ve tested it on Unity and it´t amazing, thank you! Later today we´ll get the a license.
First of all, thanks for the Unity runtime!
I'm able to get the example working in Unity, but am having some problems bringing my own animations into Unity. Here are the steps I went through, please let me know if I'm doing it wrong:
1) Within Spine, export a JSON (does pretty print matter here?). Add .txt to the end of the file since the json in the unity example is that way.
2) Within TexturePacker, create an atlas using LibGDX format. This produces a png and a txt file.
3) Within Unity, create a new material, set the shader to Spine's skeleton shader and add the atlas png generated by TexturePacker in step 2.
4) Within Unity, create a new spine atlas. In the inspector window, set the atlas file to point to the txt file generated by TexturePacker in step 2. Set the material to the one created in step 3.
5) Within Unity, create a new spine skeleton data. Set the atlas asset to the spine atlas created in step 4. Set the skeleton json to the txt file created in step 1.
6) Within Unity, create a new spine skeleton in the scene's hierarchy. In the inspector window, set the Skeleton Data Asset to the one created in step 5.
All seems to work until step 5, when I add the json to the skeleton data. There is an error:
Exception: Error reading skeleton JSON file for skeleton data asset: Test
UnityEngine.Debug:LogException(Exception, Object)
SkeletonDataAsset:GetSkeletonData(Boolean) (at Assets/src/SkeletonDataAsset.cs:53)
SkeletonComponent:Update() (at Assets/src/SkeletonComponent.cs:41)
Comparing my skeleton data asset to the Spineboy example, mine is missing Animation State Data and my spine skeleton in the scene is empty.
What am I missing?
@pxlweaver, your steps sound perfect. Seem it has trouble loading the skeleton JSON. Could you attach the JSON file to a post here in the forums or email it to contact@esotericsoftware.com? Pretty print doesn't matter, just makes it easier for humans to read.
Hey just a quick thing I noticed. It doesn't look like the slot color changing is working. I exported out the Spinosaurus example project and the button colors don't change. I dug a little deeper and saw that the skeleton shader doesn't have any coloring for its texture.
Just a few quick fixes to get it in. It doesn't edit material properties at all so it won't incur any additional draw calls.
1) Modify the shader to allow per-vertex colors. (With source alpha blend)
Shader "Skeleton"
{
Properties
{
_MainTex ("Texture to blend", 2D) = "black" {}
}
Category
{
Tags {"Queue"="Transparent"}
Cull Off
Lighting Off
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
SubShader
{
Pass
{
ColorMaterial AmbientAndDiffuse
SetTexture [_MainTex]
{
Combine texture * primary, texture * primary
}
}
}
}
}
2) Pass in the slot colors to the vertex indices that need to be colored
Color[] vertexColors = new Color[quadCount*4];
// ...... Other code to loop through vertex indices here .........
Color slotColor = new Color(slot.R, slot.G, slot.B, slot.A);
vertexColors[vertexIndex] = slotColor;
vertexColors[vertexIndex] = slotColor;
vertexColors[vertexIndex] = slotColor;
vertexColors[vertexIndex] = slotColor;
//....Finally set the meshes vertex color attributes....
mesh.colors = vertexColors;
Nate ha scritto@[cancellato], your steps sound perfect. Seem it has trouble loading the skeleton JSON. Could you attach the JSON file to a post here in the forums or email it to contact@esotericsoftware.com? Pretty print doesn't matter, just makes it easier for humans to read.
Had some problems with vague exception logs too when we had trouble loading json from Spine. Suspecting something was malformed, I even checked the json file with a validator and it was fine. XD
I couldn't trace it because, based on the code, the loader/parser in the runtime was throwing specific and helpful exceptions but the highest-level catch() block wasn't using it to log the error onto the console. (I think the highest-level is in SkeletonDataAsset.cs)
I just changed the catch() param to "catch(Exception ex)" and added "Console.DebugLog(ex);" in the block. Worked like a charm.
What mine turned out to be was that I had included some images in my spine editor project (the alignment image used in a similar way as the videos) which wasn't in my final atlas. There might be a Spine Editor feature idea in there somewhere to avoid this problem, but maybe for later.
Once I removed the alignment image from the project and re-exported the json, it worked fine.
We also ran into some problems trying to import atlases that had rotation enabled (TexturePacker has a checkbox for "allow rotation" that rotates some of the parts by 90º to make them fit better). The textures in game just went nuts. We just decided to uncheck that checkbox for now.
Rotated and whitespace stripped regions are fixed. Unity now has a goblins example and a skin select box in the Inspector.
Slot colors are fixed. Thanks again ngomes82! The shader still uses one, srcalphaminnusone because that is needed for proper blending. Images must be premultiplied.
Nate ha scritto@[cancellato], your steps sound perfect. Seem it has trouble loading the skeleton JSON. Could you attach the JSON file to a post here in the forums or email it to contact@esotericsoftware.com? Pretty print doesn't matter, just makes it easier for humans to read.
I grabbed the latest off github and now my animations work in Unity! :sun:
Nate ha scrittoSlot colors are fixed. Thanks again ngomes82! The shader still uses one, srcalphaminnusone because that is needed for proper blending. Images must be premultiplied.
Hey Nate!
I recently tried keying the colors, the alpha channel in particular, for a fading in/out effect.
It doesn't seem to be working in Unity. Is this a known bug on your end? I assume it's a shader thing.
Keyed color changes are otherwise working fine though.
Fixed in git, thanks for reporting!
Error reading skeleton JSON file for skeleton data asset: New SkeletonData
Region not found in atlas: Images/head (region)
I rebuild the animations and unity is still giving me this error. Is there a special place this atlas image needs to be?
Your skeleton component has a skeleton data which has an atlas which has an atlas file and an atlas material. That error means the skeleton data JSON tries to find a region that isn't in the atlas file. Probably your atlas just has "head" and not "Images/head". Either repack your atlas so it has "Images/" prefixes or click the images node in Spine, set the path to "Images", then rename all your images to not have the "Images/" prefix. Pro tip: double click to rename.