Hello! I am trying to remake Attorney Online in Unity and have faced several issues because of gifs

Hello! I was trying to remake Attorney Online in unity but as I told in the title I faced the issue of this program using gifs. I got quite lucky partly though. I found a program that turned gifs into sprite sheets and afterwards I found code that cut the sprite sheet into several frames. All well in that part. Until I find there are empty frames. In the beggining is not that big of an issue, I just make it have change the ammount of colums in that program I mention to have a spritesheet with no empty frames. But that breaks the talkinganimation like this. First this looks like normal:
7447448--913346--upload_2021-8-25_13-10-21.png
And this one is how the “talking one” looks:
7447448--913349--upload_2021-8-25_13-12-9.png
So I am faced with 2 posibilities, or I make the cutter detect blank spaces and leave them, or I make whatever the second thing happen…stop happening. By the way I noticed the scale of the frames. Its suposed to be 256x192, so that could be related to the second thing happening.

Here is the code that makes those cuts:

using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;

public class NameSpritesAutomatically : MonoBehaviour
{


    public static void SetSpriteNames(Texture2D textura)
    {

        Texture2D myTexture = (Texture2D)AssetDatabase.LoadAssetAtPath<Texture2D>(AssetDatabase.GetAssetPath(textura));


        string path = AssetDatabase.GetAssetPath(myTexture);
        TextureImporter ti = AssetImporter.GetAtPath(path) as TextureImporter;
        ti.spriteImportMode = SpriteImportMode.Multiple;
        ti.isReadable = true;

       

        List<SpriteMetaData> newData = new List<SpriteMetaData>();
        int SliceWidth = 256;
        int SliceHeight = 192;

        for (int i = 0; i < myTexture.width; i += SliceWidth)
        {
            for (int j = myTexture.height; j > 0; j -= SliceHeight)
            {
                SpriteMetaData smd = new SpriteMetaData();
                smd.pivot = new Vector2(0.5f, 0.5f);
                smd.alignment = 9;
                smd.name = (myTexture.height - j) / SliceHeight + ", " + i / SliceWidth;
                smd.rect = new Rect(i, j  - SliceHeight, SliceWidth, SliceHeight);

                newData.Add(smd);
               
               
            }
        }

       
       

        ti.spritesheet = newData.ToArray();

       

        AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);

    }
}

Thank you so much! and have a nice day

Looks like you (or the automated tools) are not cutting the sprites correctly.

I recommend either:

  • go back to where you got the gif cutter / importer and figure out how to get it working

  • hand-export the gifs yourself as frames and adjust them appropriately.