Cloning a Sprite with 2D Animation Preview Bones causes animation to stop working
I have a sprite which I have rigged up using the Unity 2D animation preview package.
I wanted to replace the texture on my prefab of the Sprite.
  IEnumerator PaintSprite(Texture2D texture, string spriteName, Action callback)
          {
              //Clone the default texture and apply the imported texture so that it doesnt override the original sprite material
              var copyTexture2D = Instantiate(DefaultTexture);
              copyTexture2D.SetPixels32(texture.GetPixels32());
              copyTexture2D.Apply();
              _spriteRenderer.sprite = Sprite.Create(copyTexture2D, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 400, 1, SpriteMeshType.Tight);
              
              //Let our optional callback function know that we've done copying Texture
              callback?.Invoke();
              _spriteRenderer.sprite.name = spriteName;
              yield return null;
          }
 
               Once I do this, the animations stop working on the Sprite, because it seems all the bones and bind pose information gets cleared out.
I also noticed that Sprite.Create seems to be expensive? It is blocking the main thread for about 60ms
               Comment
              
 
               
              Your answer