Unity Community |

You play animation from the begining while you holding down the left mouse button that's why you see the first frame.
if(!anim.isPlaying || anim.CurrentClip.name != "High Acceleration 1")
anim.Play("High Acceleration 1");
Hi! I have a problem with my build. I create sprites and sprite animations with script and if I click play button in unity everything is ok. But then I build my project sprites and animations dont work. I try different ways to create
GameObject go = new GameObject();
tk2dSprite sprite = go.AddComponent<tk2dSprite>();
sprite.SwitchCollectionAndSprite(data, 0);
sprite.Build();
I try to load collection from Resources, I try to instantiate from a prefab, and in game view everything is ok, but after building it doesnt work. Target platform is PC.
How do you get data? Also, what file do you store in the resources folder?
Last edited by unikron; 04-20-2012 at 02:16 AM.
Thanks for the source files to reproduce this - As explained in the email, this is caused by a discrepancy with the ortho size and the sprite position you picked, ended up not being on a pixel center.I think it happened to me as well. I was testing various 2d plugins the other day, and find out that the sprite created from toolkit2d is blurry unlike the others. At first I thought it's because of my raw asset files, so I change them to psd. Once switched to psd, the other plugins are noticeably sharper, while toolkit2d sprite was still blurry.
A simple solution to this is to use the tk2dCamera, where every round number in world space is guaranteed to be a pixel boundary.
I solved the problem. First of all I used sprite.spriteId = sprite.collection.GetSpriteIdByName("spriteName"); instead sprite.spriteId = sprite.GetSpriteIdByName("spriteName"); I have two prefabs for sprite and sprite animation and both of them for default used collection which not included in build thats why arisen exeption. I switch default collection and animation. Now everything fine. Thanks.
P.S. I think it would be greate idea to make SpriteCollection without reference to source textures and work only with atlas. For example I have a huge number of images and when switch between platforms Unity crashes. I have to create new project for each platform and initialize animation and sprite collections from the begining.
That is an interesting request, but a lot of the features would not be usable, which is why I haven't implemented it. One example is sprite dicing. I have had some need for this though, so I am considering it.
I was thinking of some optimizations to make the SpriteCollection build require significantly less resources, and remove all references to the source textures themselves - would that help in your case?
@unikron is there a way to avoid/hide the "divisions" shown of a sprite with dicing when scaling?
Thanks for your response.
I apologize it was my problem. The images are actually rendered correctly as crosses (my sample placeholders) when they become small. Just because they are rendered as crosses I thought they rendered incorrectly.
Is there any plan to add more features to the button class? e.g.
- support Time.timeScale = 0
- a method to change the shown image
If you have no time doing so, I may help adding the second feature and releasing a modified one here. I don't know how to solve the first problem.
Thanks very much for your time.
When scaling up there should be no seams.
When scaling down - you can get better results by increasing padding, or setting point filtering. Both can and will fail in various different ways, though.This is inevitable due to how graphics hardware works.Start with some really large padding amount and scale down from there to see what works best for you.
Time.timeScale = 0, that will be fixed in the next release. Drop me an email at support at unikronsoftware dot com to get this script sooner if you want.Thanks for your response.
I apologize it was my problem. The images are actually rendered correctly as crosses (my sample placeholders) when they become small. Just because they are rendered as crosses I thought they rendered incorrectly.
Is there any plan to add more features to the button class? e.g.
- support Time.timeScale = 0
- a method to change the shown image
If you have no time doing so, I may help adding the second feature and releasing a modified one here. I don't know how to solve the first problem.
Thanks very much for your time.
with the second one, do you mean changing it from script?
Hi, I couldn't find anything in the docs about adding many fonts to a single Sprite Collection. After some trial and error, I came up with the following workflow. Does this sound correct? If so, please feel free to add these steps to the 2DTK docs.
1. create a new Sprite Collection
2. open the sprite collection editor
3. click Create and then select Font
4. drag the exported fonts .fnt file into the BM Font slot (note I made my font with Glyph designer)
5. drag the exported fonts .png into the Font Texture slot*
6. click the Create button in the area that says "A data object is required to build a font."
7. select a folder for the .prefab
8. click Commit in the Sprite Collector and now the font should be available on a Text Mesh.
*Note at this point an additional field appeared in the Sprite Collector that says "the texture importer needs to be reconfigured to be used as a font texture source. Please not that this will globally change this texture importer" along with a button that says "Set up".
Last edited by meanstreak; 04-21-2012 at 04:28 PM.
Tim Miller, Designer at Rocket 5 Studios @rocket5studios, Unity3D Tutorials
Our games: Holeshot Drag Racing, Giant Moto, Small Space
Thats pretty much it - sorry about the lack of docs on that, its been one hectic month. Thanks for the steps, I'll get that added to the docs (and the other undocumented features) as soon as I can together with some screengrabs.
Edit: did you have any trouble figuring it out? If so, where? I spent a great deal of time working out a clear workflow in the new sprite collection editor, and the idea is there shouldn't be many places things could go wrong, so if something wasn't clear, etc. please let me know so I'll know what to address.
Last edited by unikron; 04-21-2012 at 04:58 PM.
Yeah figuring out the correct order was a bit trial and error - like you have to click the Create button before you click the Commit button. First time I tried I did it the other way around which didn't work. On a side note I sometimes forget to press the Commit button at all because it's kind of small and not very obvious.Edit: did you have any trouble figuring it out? If so, where? I spent a great deal of time working out a clear workflow in the new sprite collection editor, and the idea is there shouldn't be many places things could go wrong, so if something wasn't clear, etc. please let me know so I'll know what to address.
I had originally made all my fonts using the old method and I tried to recreate them with the Sprite Collection editor but they weren't being created properly - everything looked fine with the files but the glyphs were solid white in the Atlas. So my workaround was to re-export from Glyph Designer and then make them fresh with the Sprite Collection editor.
Tim Miller, Designer at Rocket 5 Studios @rocket5studios, Unity3D Tutorials
Our games: Holeshot Drag Racing, Giant Moto, Small Space
Good point about the create button - perhaps I should add some inline messagebox stating that it won't work until the object has been created. I'll get the docs done before revisiting this.
Thanks for the feedback, its much appreciated.
Did you get any messages in the console when the fonts ended up solid white? It could be because they weren't marked "Read/Write Enabled" - the "Set up" button sorts that out for you.
Last edited by unikron; 04-21-2012 at 05:37 PM.
I did get some messages in the console, but didn't copy them down. But now that you mention it, the "set up" button didn't appear in the cases where the font ended up being solid white. An easy test to reproduce on your end would be to make a font the old way, then delete the data and prefab files that get created with that process (since they get created again in the next step), and then try to add that same .fnt and .png to a sprite collection.
Tim Miller, Designer at Rocket 5 Studios @rocket5studios, Unity3D Tutorials
Our games: Holeshot Drag Racing, Giant Moto, Small Space
Thanks very much for your prompt reply and solving the problem.
Yes, I mean changing from script. Moreover, I hope you will add a feature (add a few more public string variables for sprite names of a toggled state) to toggle the state of the button that, for example, when a "Pause" button is pressed (stays as pressed until clicked again), it's shown as "Play" and when it's released it's shown as "Pause", so that I don't need to change the shown image from script.
Does global changing in Prefab not work (propagate) for the parameters in AnimatedSprite in Inspector?
Thanks very much for your time!
That worked with the fonts I tested, but those were pngs from BMFont - I'll test this using GlyphDesigner next time I'm on my mac. Thanks for taking the time to report this.I did get some messages in the console, but didn't copy them down. But now that you mention it, the "set up" button didn't appear in the cases where the font ended up being solid white. An easy test to reproduce on your end would be to make a font the old way, then delete the data and prefab files that get created with that process (since they get created again in the next step), and then try to add that same .fnt and .png to a sprite collection.
I'll put that in the TODO, but I don't think it'll be done in time for 1.70.Thanks very much for your prompt reply and solving the problem.
Yes, I mean changing from script. Moreover, I hope you will add a feature (add a few more public string variables for sprite names of a toggled state) to toggle the state of the button that, for example, when a "Pause" button is pressed (stays as pressed until clicked again), it's shown as "Play" and when it's released it's shown as "Pause", so that I don't need to change the shown image from script.
Does global changing in Prefab not work (propagate) for the parameters in AnimatedSprite in Inspector?
Thanks very much for your time!
Hi, I´m trying to decide wish framework to go with. I´v made a thread on the gossip part, wish got buried, explaining my needs
Basically I want to stack images (finished) on top of each other, aplly colliders where do, and work out the logic (dont want to mess with shaders and animation inside unity, at list not for now)
Don´t want to clutter the thread so after the jump...
would you say 2dToolkit is for me? Do you foresee any shortcomings?
thanks
How do you add in multiline text from code? If I have a string "First line\nSecond Line" and add it to the text mesh it doesn't seem to work![]()