2D Toolkit Forum
2D Toolkit => Support => Topic started by: bryanB on September 23, 2013, 07:12:23 am
-
I am currently adding texture during runtime and noticed that I need to play all the animations in order to access the correct collection and set the textures. Is there any other way to do this? I would like to eliminate playing every animation upon setting the correct textures.
Thanks in advance!
-
I don't understand why you'd need to play all animations to set the textures - what exactly are you trying to do here? How are you adding the texture and what does this texture contain?
-
our objective is to optimize our asset bundles. We started by removing the textures of each animation material. basically these textures are the atlases of the animations I play. To access the different collections per animation I play the animation then add the textures by "animSprite.Collection.materials.mainTexture = texture;".
-
You can simply iterate through all the clips -
foreach (var clip in animSprite.Library.clips) {
foreach (var frame in clip.frames) {
if (frame.spriteCollection.materials[0]....) { // assign if null
}
}
}