Harald
Thank you for pointing out the issue with using Spine in URP, which helped me better understand this software.
My colleagues and I opened AssetBundle in AssetStudio and found that the URP Spine Shader referenced by the resource was incorrect. However, I was able to ensure that my settings were correct in Unity Editor. Therefore, after downloading AssetBundle, I reset the SkeletonDataAsset
in the SkeletonAnimation
and reassigned the Shader
to the Material
before reinitializing the animation, I finally got the right result! π€
Here is the code for me to download SkeletonDataAsset
and Material
and reset SkeletonAnimation
SkeletonAnimation skeletonAnimation;
SkeletonDataAsset skeletonDataAsset;
GameObject spineGO;
Material spineMaterial_1;
Material spineMaterial_2;
public void OnEnterFight()
{
GeometryGameObject = Instantiate(GameEntry.Res.GetAsset<GameObject>("Geometry_Geometry").AssetObject as GameObject);
spineGO = GeometryGameObject.FindGameObjbyName("SpineBoy");
skeletonAnimation = spineGO.GetComponent<SkeletonAnimation>();
GameEntry.Res.LoadAsset<SkeletonDataAsset>("bleed_spineboy-pro_SkeletonData", (handle) =>
{
skeletonDataAsset = handle.AssetObject as SkeletonDataAsset;
Log.Debug("Skeleton Download OK");
CheckDownLoad();
});
GameEntry.Res.LoadAsset<Material>("bleed_spineboy-pro_Material", (handle) =>
{
spineMaterial_1 = handle.AssetObject as Material;
spineMaterial_1.shader = Shader.Find("Universal Render Pipeline/Spine/Skeleton");
Log.Debug("mat1 Download OK");
CheckDownLoad();
});
GameEntry.Res.LoadAsset<Material>("bleed_spineboy-pro_Material-Additive", (handle) =>
{
spineMaterial_2 = handle.AssetObject as Material;
spineMaterial_2.shader = Shader.Find("Universal Render Pipeline/Spine/Blend Modes/Skeleton Additive");
Log.Debug("mat2 Download OK");
CheckDownLoad();
});
}
public int count = 0;
private void CheckDownLoad()
{
count++;
if (count==3)
{
skeletonAnimation.skeletonDataAsset = skeletonDataAsset;
skeletonAnimation.Initialize(true);
skeletonAnimation.initialSkinName = "default";
skeletonAnimation.AnimationName = "jump";
}
}
But I still haven't figured out what happened, causing the material references in AssetBundle to change inexplicably. As can be seen from the screenshot I provided below, my strategy for packaging AssetBundle is to only package "Prefab" and have it automatically reference the required materials and shaders. Although I have already solved this problem (re assigning and initializing the aforementioned things), But I think this issue may be a Unity issue.