SomeTallGy

Hi folks, this is my first time attempting to load spine animated characters through an asset bundle. I am getting a problem in which the prefab loads and gets instantiated into my scene but the Spine/Skeleton shaders do not appear to be working (getting the pink textures)

Here is a snippet from my editor.log
WARNING: Shader Unsupported: 'Spine/Skeleton' - Pass '' has no vertex shader
WARNING: Shader Unsupported: 'Spine/Skeleton' - Pass '' has no vertex shader
WARNING: Shader Unsupported: 'Spine/Skeleton' - Setting to default shader.
Please also note that I do have the Spine/Skeleton shader in my "Always Included Shaders" in my project's graphic settings.

I ran through searching the forums as well as google to try to see if I am missing a step here but have come up short :sweat:

Am I missing something else?

Any thoughts or help would be appreciated!!
SomeTallGy
  • Сообщения: 2

Pharan

But they work fine when they're not in asset bundles?
If so, it's not a shader problem.

See this post. Another user has experimented with setups and found some glaring problems on the Unity end of things, and has some workarounds.
HD/SD Assets and Asset Bundle Issues
Аватара пользователя
Pharan
  • Сообщения: 5366

SomeTallGy

Hi, thank you for replying!

Yes they work fine in any other given situation. I assumed it was a shader problem since if I manually set problem shaders in the inspector to spine/skeleton, again, the textures then display correctly.

I am wrapping my head around the post you linked and will try to see if i can work out a solution from it. Thanks again for linking that.

I'll keep you posted!

-- 04 Oct 2016, 13:54 --

Okay -- After further searching, I seem to have found a hack to fix this.
var materials = bundle.LoadAllAssets<Material>();
foreach(Material m in materials)
{
var shaderName = m.shader.name;
var newShader = Shader.Find(shaderName);
if(newShader != null)
{
m.shader = newShader;
}
else
{
Debug.LogWarning("unable to refresh shader: "+shaderName+" in material "+m.name);
}
}
The above code essentially refreshes your material's shaders to find the shader of the same name. This seems to work.
One caveat though is that you need to be sure to include your materials that are being used on your spine character within the bundle -- so you can access the Material(s) directly with the above code.

I am not sure if this is the cleanest workaround, but it seems to work for me so far.
SomeTallGy
  • Сообщения: 2

Pharan

Thanks for sharing!
There are certainly any number of ways you could bundle your Spine assets.
It's unfortunate that the asset bundle system has all these problems, undocumented limitations.
Аватара пользователя
Pharan
  • Сообщения: 5366

水岸上

I find a simple way that is for the component of SkeletonGraphic and SkeletonRenderer SkeletonAnimation to resolve the assetbunle-pink-problem.

1.put two shader of Skeleton and SkeletonGraphic into a Resources folder.

2.add code into SkeletonGraphic :
protected override void Start()
{
base.Start();
material = new Material(Resources.Load<Shader>("SkeletonGraphic"));
}
3.the SkeletonAnimation is the subclass of the SkeletonRenderer, so only in the SkeletonRenderer add code:
public virtual System.Collections.IEnumerator Start()
{
yield return 0;
var mat = new Material(meshRenderer.material);
mat.shader = Resources.Load<Shader>("Skeleton");
meshRenderer.material = mat;
}
and then when we load assetbundle that made by spine, it will be set right shader and displays normally.
水岸上
  • Сообщения: 2

Benzino

I have had this issue before (not with Spine, but just other assets) and the problem for us was we built the asset bundles for the wrong target. For us, we had the platform set to iOS and building the asset bundles for iOS. But when running in the editor, everything was pink because even though our platform was set to iOS, because the game was running in the editor it was expecting asset bundles for the editor (in our case for mac as that is our OS).

Just something that might be the cause.
Benzino
  • Сообщения: 12

Wecica

Benzino писал(а):I have had this issue before (not with Spine, but just other assets) and the problem for us as we built the asset bundles for the wrong target. For us, we had the platform set to iOS and building the asset bundles for iOS. But when running in the editor, everything was pink because even though our platform was set to iOS, because the game was running in the editor it was expecting asset bundles for the editor (in our case for mac as that is our OS).

Just something that might be the cause.
Thanks for your tips. We found out that it actually is the platform problem. It can't display correctly when we run our game in Editor mode but build the asset bundles for the Android platform.
8)
Wecica
  • Сообщения: 13


Вернуться в Unity