Changing atlas without changing sprite's name

More
4 years 6 months ago #417 by Neri
Is there a way to change only Sprite's atlas?

Even if I set Main term to <none>, it still overwrites sprite's name. It's fine for static game objects where I can just create term for sprite's name with all same values, but if I want to change sprite's name at runtime while keeping language-specific atlas, localization plugin just overwrites the name.

I'm using version 2.2.0b1.

Please Log in or Create an account to join the conversation.

More
4 years 6 months ago #418 by Frank
Hi,
The plugin was not handling that case.

To make it avoid setting the MainTranslation but still do the Atlas switching, you will have to go the file corresponding to the target plugin you are using.
They are in Scripts/Targets
So, that if you are using NGUI, it will be Script/Tagets/LocalizeNGUI.cs

Then find the function
public void DoLocalize_UISprite(string MainTranslation, string SecondaryTranslation)

And change the lines:
			if (mTarget_UISprite.spriteName != MainTranslation)
			{
				mTarget_UISprite.spriteName = MainTranslation;
				bChanged = true;
			}

into
			if (mTarget_UISprite.spriteName != MainTranslation && mTarget_UISprite.atlas.GetSprite(MainTranslation)!=null)
			{
				mTarget_UISprite.spriteName = MainTranslation;
				bChanged = true;
			}

That will skip setting the sprite name if the sprite translation wasn't set or the sprite is not valid.
Be aware that if no Term for the sprite is set, the plugin uses the SpriteName that is set to the UISprite component in the Editor.
So, you will have to assign no sprite to the UISprite. And then assign a valid sprite at runtime.
That way,the plugin will start, will try getting the spritename from the one you selected in the IDE, but will get nothing as there is no sprite. And MainTranslation will be empty. So that it will never be a valid sprite and so it will skip that step.

Let me know if that helps, otherwise I can send you an example scene. You can email me at This email address is being protected from spambots. You need JavaScript enabled to view it.
Thanks,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

More
4 years 6 months ago #425 by Neri
Hey Frank,

Thanks for the tip!
The code in 2.2.0 version was a little different, but I modified it to suit my needs.

By the way, is there a way to set a font for the whole language without having to do it individually on every label?

Please Log in or Create an account to join the conversation.

More
4 years 6 months ago - 4 years 6 months ago #426 by Frank
Great!

Yes, there is a way. Normally, if you don't supply a secondary term, the labels will use the Font name.
So, if all your labels are using the Arial font, you just need to create a term named "Arial" and define the font you want to use for each language. (the term name has to be exactly the font name)

That way, when localizing, it will change the font of all labels that don't set a secondary term.

Hope that helps,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
Last edit: 4 years 6 months ago by Frank.

Please Log in or Create an account to join the conversation.

More
4 years 6 months ago #427 by Neri
That sounds good, but I can't get it to work for some reason.
What types do these terms need to be?

Please Log in or Create an account to join the conversation.

More
4 years 6 months ago #428 by Frank
You should be following the same steps like in here:
inter-illusion.com/tools/i2-localization...ge-font-per-language

Just don't set the secondary term of the labels. And check that the name of the font you are using matches the name of the Term.

If you can't get it work property, I can send you an example scene with that setup. Just let me know what target are you using (NGUI, DFGUI, etc) and what type of fonts you using (Bitmap fonts, dynamic fonts, etc)

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

Time to create page: 0.263 seconds
Template by JoomlaShine