- Home /
How can I interacte with Sprites from a Texture with Sprite Mode multi?
I through the code using Resources to load a specific Texture getting all cropped sprites properties but what I need is to bind Textures from the Unity Editor.
So far I do like this:
var sprites = Resources.LoadAll<Sprite>("TilesPack");
foreach (var sprite in sprites)
{
Debug.Log("Texture: " + sprite.name);
}
I did a public Texture2D however I see no properties to walking through all sprites, just methods to manipulate pixels, colors and so on.
What I suppose to do to reach that?
Thanks in advance
Comment
Best Answer
Answer by Dunkelheit · Aug 08, 2014 at 07:48 PM
I figured out how to approach it:
Replace Resources.LoadAll(); for:
var spriteSheet = AssetDatabase.GetAssetPath(Sprites);
var spriteArray = AssetDatabase.LoadAllAssetsAtPath(spriteSheet).OfType<Sprite>().ToArray();
foreach (var sprite in spriteArray)
{
Debug.Log("Texture: " + sprite.name);
}
Your answer
Follow this Question
Related Questions
Tilemap: Resizing Tiles? 1 Answer
Black boarder on transparent sprites 2 Answers
Merging Two Images 2 Answers
Unity2D Tilemap Add Sprites with Normal Maps to tilePallet 2 Answers