• Editor
  • Unity and C# runtimes, more videos

Related Discussions
...
  • Изменено
  1. Thank you so much for this! I'm particularly happy about the fact that it has no dependencies on other plug-ins. I have essentially zero dollars right now and I've just barely scrapped together the money to support Spine on Kickstarter (after supporting Spriter however long ago when they ran theirs) and I was not looking forward to having to either learn Futile or purchase 2D Toolkit. Making it standalone is a pleasant surprise and I appreciate that.

  2. Umm...how do I download it? I'm very new to GitHub (signed up today) and I don't understand what I need to do. Could someone perhaps point me in the right direction?

Hi rxninja,

To download the source you can either click the "ZIP" button, so it will download the entire source packed as a ZIP, or you can download and sync to the spine repo in github, you can just download the github PC client, set it and drag the Spine repository URL, it will begin to sync the repo. I prefer this way because it will be easier to stay up-to-date for changes/fixes.

Yep, as Cuellarjmcg. Zip is easiest, otherwise I recommend SmartGit, which is free for personal use.

Thanks a lot for getting the Unity runtime out. It's working great!

Cuellarjmcg написал

Hi rxninja,

To download the source you can either click the "ZIP" button, so it will download the entire source packed as a ZIP, or you can download and sync to the spine repo in github, you can just download the github PC client, set it and drag the Spine repository URL, it will begin to sync the repo. I prefer this way because it will be easier to stay up-to-date for changes/fixes.

I understood some of those words. I think I can figure it out from there haha.

EDIT: Nope, I lied. I don't see a "ZIP" button anywhere on the page. I also tried downloading multiple Git clients and none of them make a lick of sense to me. Hoo boy.

I successfully imported the Unity runtime, and tested the performance.

With 30 spineboys in screen ,the performance is perfect! :yes:

And here is a tiny question :

In Unity example, the images are combined into atlas (1 big image and 1 "*.atlas" description file), while in editor's folder they are separated images.

How to created the atlas file ? Is there some tool to combine the images into atlas?

Nate написал

zephyr1125, sure:
http://code.google.com/p/libgdx/wiki/TexturePacker
http://texturepacker.com/
Note that Unity needs the images to have premuliplied alpha (a setting in the packer).

rxninja, there's a ZIP button, keep looking. :p Here:
https://github.com/EsotericSoftware/spi ... master.zip

Thank you! I downloaded the TexturePacker, but which output data format to choose ?

Oops, forgot to mention, it's the libgdx format.

I'm not crazy. There's no ZIP button for me. I thought it was just my GitHub ineptitude, but there is legitimately no button.

 Loading Image

I got it from Nate's last link, but bugging the dev every time there's an update seems to be a fairly inefficient use of everyone's time.

Thoughts?

On a semi-related note, I really don't understand how to use this runtime. If anyone more experienced and competent were to make a tutorial video on how to get everything up and running and how to use some of the features like dynamic image swapping (e.g. to swap out a character's outfit), that would be super helpful. I know I would appreciate it and I bet it would also help others who are fairly new to Unity and the code-centric side of things (I'm coming from a moderate Photoshop/Illustrator background with light experience in QBASIC and VBas).

The link I posted is github's link, it will always download the latest. Click "CODE" in github to see the zip button.

Did you see the Unity example project? You can play an animation that changes an image. You can use the C# API, eg:

gameobject.GetComponent<SkeletonComponent>().skeleton.SetAttachment("slot name", "attachment name");

It may be some time until there are proper docs.

Cool video from twitter, using Unity:
http://t.co/iBsRp06iFE

This is awesome! The runtime is super efficient. Just a couple of little things I noticed when checking out the runtime.

1) Data asset creation - It looks like it always creates in the "Assets/" folder. It'd be nice if it created in your currently selected folder. Super small thing but I can see it preventing some whining haha.

[MenuItem("Assets/Create/Spine/Spine Atlas")]
static public void CreateAtlas() 
{
	string path = EditorUtility.GetAssetPath(Selection.activeObject) + "/SpineAtlasData";
	CreateAsset<AtlasAsset>(path);
}

2) Bones as GameObjects - Im not sure how inefficient it is to have bones as individual game objects. I think it would boost the flexibility of using spine in Unity. It would allow designers to add box colliders, scripts, and components to specific bones. AFAIK large numbers of objects is pretty minimal performance-wise. It's the scripts that run on them and the draw calls that impact performance the most.

Thanks for taking a look. 🙂

I'll add the GetAssetPath, thanks!

You may be right about the game objects. I've read about Unity's dynamic batching, which does batching across game objects (though it is limited to only 300 vertices, interestingly). However, I have a feeling most usage will not need a game object per bone. When we have bounding boxes, it would make sense to create colliders for those. I'm open to potentially adding game-object-per-bone rendering in the future, but right now I still need to integrate better with 2D Toolkit and all the other tasks.

Great job, guys! It's working pretty efficiently.

Anyway, I dunno if this a known bug or something you haven't implemented yet for everything.

I tried making a few basic looping animations (a bunch of rectangles rotating 90º back and forth with different interpolation curves) and it seems like the curve data in the JSON aren't being followed by the Unity/C# runtime. Everything is animating linearly regardless of the curve data except for the Stepped variety which functions correctly.

There was a bug with curves in spine-csharp. Fixed now, thanks! 🙂

Sweet! 🙂 Unity certainly makes it easy to demo. Shiu, maybe we should put together some animations for a Spine webpage? 🙂

Certainly! 🙂 I'll look into Unity

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 написал

@[удалено], 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.

Thanks ngomes82! I'll make those changes. 🙂

@Pharan, unforutunately DebugLog(ex) isn't available in Unity 3.5. 🙁 I'll make sure it prints out something useful. I'll also look into rotated regions.

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 написал

@[удалено], 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:

9 дней спустя
Nate написал

Slot 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! 🙂

5 дней спустя

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.