public void OnPostprocessTexture(Texture2D texture) { // Do nothing if it not a LPC Based Sprite if (!IsLpcSpriteSheet(texture)) { return; } Debug.Log("Importing LPC Character Sheet"); List <SpriteMetaData> metas = new List <SpriteMetaData>(); for (int row = 0; row < m_RowCount; ++row) { for (int col = 0; col < m_ColCount; ++col) { SpriteMetaData meta = new SpriteMetaData(); meta.rect = new Rect(col * LPC_SPRITE_SIZE, row * LPC_SPRITE_SIZE, LPC_SPRITE_SIZE, LPC_SPRITE_SIZE); LpcAnimationState animState = GetAnimationState(row); if (!m_ImportEmptySprites) { if ((animState == LpcAnimationState.Hurt && col >= m_HuFrames)) { break; } if ((animState == LpcAnimationState.Shoot && col >= m_ShFrames)) { break; } if ((animState == LpcAnimationState.Slash && col >= m_SlFrames)) { break; } if ((animState == LpcAnimationState.Thrust && col >= m_ThFrames)) { break; } if ((animState == LpcAnimationState.Walkcycle && col >= m_WcFrames)) { break; } if ((animState == LpcAnimationState.Spellcast && col >= m_ScFrames)) { break; } } string namePrefix = ResolveLpcNamePrefix(row); meta.name = namePrefix + col; metas.Add(meta); } } TextureImporter textureImporter = (TextureImporter)assetImporter; textureImporter.spritesheet = metas.ToArray(); }
public void OnPostprocessTexture(Texture2D texture) { // Do nothing if it not a LPC Based Sprite if (!IsLpcSpriteSheet(texture)) { return; } Debug.Log("Importing LPC Character Sheet"); List <SpriteMetaData> metas = new List <SpriteMetaData>(); for (int row = 0; row < m_RowCount; ++row) { for (int col = 0; col < m_ColCount; ++col) { SpriteMetaData meta = new SpriteMetaData(); meta.rect = new Rect(col * LPC_SPRITE_SIZE, row * LPC_SPRITE_SIZE, LPC_SPRITE_SIZE, LPC_SPRITE_SIZE); LpcAnimationState animState = GetAnimationState(row); if (!m_ImportEmptySprites) { if ((animState == LpcAnimationState.Hurt && col >= m_HuFrames)) { break; } if ((animState == LpcAnimationState.Shoot && col >= m_ShFrames)) { break; } if ((animState == LpcAnimationState.Slash && col >= m_SlFrames)) { break; } if ((animState == LpcAnimationState.Thrust && col >= m_ThFrames)) { break; } if ((animState == LpcAnimationState.Walkcycle && col >= m_WcFrames)) { break; } if ((animState == LpcAnimationState.Spellcast && col >= m_ScFrames)) { break; } } string[] path_branch = assetImporter.assetPath.Split('/'); //Debug.Log("SPRITE PATH: " + assetImporter.assetPath); string prefix = ""; for (int i = 4; i < path_branch.Length; i++) { string node = path_branch[i]; string[] split_node = node.Split('.'); //Debug.Log("PATH BRANCH: " + node); prefix += string.Format("{0}_", split_node[0]); } //Debug.Log("SPRITE PREFIX:" + prefix); string namePrefix = ResolveLpcNamePrefix(row, prefix); //Debug.Log("SPRITE COLUMN: " + col); meta.name = namePrefix + col; Debug.Log("SPRITE NAME: " + meta.name); metas.Add(meta); } } TextureImporter textureImporter = (TextureImporter)assetImporter; textureImporter.spritesheet = metas.ToArray(); }