Have a Mesh with a Material on it

More
7 years 6 months ago #1759 by alan2110
I have a Mesh Renderer with a Material on it and the Material has a texture that I want to localize.
What would be the best way to do it? I tried adding a localized Material entry and then when I add a Localize component onto my object that has a Mesh Renderer, the Localize component has no target to link to.

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

More
7 years 6 months ago #1762 by Frank
Hi,
The current version doesn't allow localizing the texture of a material in a MeshRenderer. It can change the textures in UI elements, and the materials but no the MeshRenderer.
Adding new targets is really easy so I will definitively add that in the next release!

In the meantime, a workaround you can use is to add a Localize component to the MeshRenderer (even if the component doesn't show any target, it will execute the callbacks). So, create an script and add the following callback to the localize component.
	public class TextureCallback : MonoBehaviour 
	{
		public void OnModifyLocalization()
		{
			if (string.IsNullOrEmpty(Localize.MainTranslation))
				return;

			var mesh = GetComponent<MeshRenderer>();
			var loc = GetComponent<I2.Loc.Localize>();

			var texture = loc.FindTranslatedObject<Texture>(Localize.MainTranslation);

			mesh.material.mainTexture = texture;
		}
	}

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

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

More
7 years 6 months ago #1764 by alan2110
Thanks, that did the trick!

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

More
6 years 7 months ago #2441 by rsodre
Still cant localize a MeshRenderer? :(
That's a surprise, i tought it was so trival since we have material terms.
Well, i\I'll have to write some code then.

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

More
6 years 7 months ago #2442 by Frank

Still cant localize a MeshRenderer?


You can localize Prefabs, if that's what you are referring.
In the Standard Component Example Scene, there is a mesh that is localized (in one language it shows a Sphere, in other it shows a cube, etc).

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

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

More
6 years 7 months ago #2443 by rsodre
I actually want to localize the material of a mesh renderer.
Would be nice if the Localize script could select the MeshRenderer as target and then select a Material OR Texture term

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

Time to create page: 0.160 seconds
Template by JoomlaShine