- Home /
Adding sprites to "Objects for Packing" list in a SpriteAtlas through code?
Greetings,
so I just found out about SpriteAtlas and that you could now explicitly create these assets and have references to them in code which is super handy. But as usual with almost any Unity feature, the API is not well exposed. I want to be able to add sprites to the packing list from code in editor.
I've looked into the code of this editor in ILSpy, it seems like they're using SerializedProperty/Object and accessing the data off of a m_EditorData field. But looking at the SpriteAtlas class, that field doesn't exist anywhere, not even private. So not sure where that field exists, C++ side only maybe? Doesn't make sense cause not sure how that would be marshled in that case... If i read the .spriteatlas flie in a text editor, I can see all the values for the sprites in the file. Just no straight forward way to load it in code.
So does anyone know how to add sprites to an atlas via code in editor?
Thanks
Your answer
![](https://koobas.hobune.stream/wayback/20220612150545im_/https://answers.unity.com/themes/thub/images/avi.jpg)