Welcome, Guest
Username: Password: Remember me

TOPIC: Have a Mesh with a Material on it

Have a Mesh with a Material on it 11 months 4 weeks ago #1759

  • alan2110
  • alan2110's Avatar
  • Offline
  • New Member
  • Posts: 8
  • Karma: 0
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.
The administrator has disabled public write access.

Have a Mesh with a Material on it 11 months 4 weeks ago #1762

  • Frank
  • Frank's Avatar
  • Offline
  • Administrator
  • Posts: 853
  • Thank you received: 185
  • Karma: 55
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
The administrator has disabled public write access.

Have a Mesh with a Material on it 11 months 3 weeks ago #1764

  • alan2110
  • alan2110's Avatar
  • Offline
  • New Member
  • Posts: 8
  • Karma: 0
Thanks, that did the trick!
The administrator has disabled public write access.

Have a Mesh with a Material on it 6 days 13 hours ago #2441

  • rsodre
  • rsodre's Avatar
  • Offline
  • New Member
  • Posts: 2
  • Karma: 0
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.
The administrator has disabled public write access.

Have a Mesh with a Material on it 6 days 13 hours ago #2442

  • Frank
  • Frank's Avatar
  • Offline
  • Administrator
  • Posts: 853
  • Thank you received: 185
  • Karma: 55
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
The administrator has disabled public write access.

Have a Mesh with a Material on it 6 days 12 hours ago #2443

  • rsodre
  • rsodre's Avatar
  • Offline
  • New Member
  • Posts: 2
  • Karma: 0
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
The administrator has disabled public write access.
Time to create page: 0.089 seconds
Colors