May i get all sprites in a Multiple sprite mode texture?

The texture is multiple sprite mode.
And i can see all the sprites in the project view.
But i cant find any API to get all the sprites by code!
Can somebody help me!!!
Thanks!!

Given the path to the texture, you will need to call

AssetDatabase.LoadAllAssetsAtPath (Unity - Scripting API: AssetDatabase.LoadAllAssetsAtPath)
and filter the Object[ ] array by Sprite class.

Object[] objs = AssetDatabase.LoadAllAssetsAtPath("Assets/myTexture");

foreach(Object o in objs)
{
    if(o as Sprite != null)
    { // this is a sprite object
    }
}

Note that this only works in Editor.

2 Likes

You sovle my problem,Thanks!