Hi guys, I have the app's spritesheet in the cloud and the app download it on demand. But, I don't know how to create the sprites programatically. I have the png file(the spritesheet) and the plist file (definition of the sprites) and I can't find how to use it. Or maybe there is something else? And then I have to create a 2d animation based on the sprites. Is it possible? Any help? Thanks!
You can split up a sprite sheet, but it will need to be a texture read/write, now unity can produce a second data file(atlas I think), but you will need plus or pro licence for that I beleive, how often are you getting the file for the internet, and why?
I'm running into the same issue: my images are generated from a Camera stream and saved on disk. I'm trying to create a SpriteSheet once I got the images (they're post processed by some OpenCV script) and then save it (so it won't be generated again). Is there any script (paid or not) to do that? @piggybank1974 you mention a plus or pro licence for the atlas. Could you give more informations?
Can you use an asset bundle for your sprites? These can be downloaded or read from the filesystem. https://unity3d.com/learn/tutorials/topics/best-practices/guide-assetbundles-and-resources If your sprite sheet isn't dynamic, it is probably easier to create the sprites and animations in Unity and then export them as an asset bundle to be downloaded once needed. If your sprite sheet is dynamic or you don't want to use bundles, then download it to your resource folder and use resource load to load it into Unity: https://docs.unity3d.com/ScriptReference/Resources.Load.html. Then build the sprites using: https://docs.unity3d.com/ScriptReference/Sprite.Create.html. This is a pretty good resource that I used when I did something similar: http://answers.unity3d.com/questions/1080430/create-animation-clip-from-sprites-programmaticall.html And, no, you don't need Unity Pro or Plus.
Thanks for the quick answer @PGJ! Well my Unity project is almost a blank project (regarding images), they are grabbed at runtime from the Camera and OpenCV (still a Unity process) then saved on disk. The idea is to turn this images into SpriteSheets at runtime and save them on disk so later they won't be regenerated. Since everything is dynamic and Unity Editor isn't running, I think I can't use AssetBundle, right? Sprite.Create sounds great to create a Sprite with Sprite Mode set to Single, but not for Multiple or I'm missing something?
You don't really need to care for Single/Multiple in this case. Do something like this: Code (CSharp): int width = 5; int height = 5; Texture2D mySpriteSheet = Resources.Load("mySpriteSheet") as Texture2D; List<Sprite> mySprites = new List<Sprite>(); for (int y = 0; y < 5; y++) { for (int x = 0; x < 5; x++) { Sprite newSprite = Sprite.Create( mySpriteSheet, new Rect(x * width, y * height, width, height), new Vector2(width / 2, height / 2)); mySprites.Add(newSprite); } } I haven't really tested the code above, but it should be more or less correct.