- Home /
Can I assign multiple materials to an object that has single mesh.
Hi. I'm working on a new asset creating. I have an issue to only iOS. That is what I can't assign multiple materials onto an object that has single mesh.
I tried to do it manually. I tried to assign any material onto a material list in MeshRenderer's material property in the inspector. It works well on PC / Mac. But I builded it to iOS, it didn't work on an iOS device.
I got an advice for it. He said, "Multiple materials are not defined, so you should duplicate an object or to use another way."
But it works well on PC / Mac. I want to know about working well on only iOS devices.
I show a code snippet of my script.
Material[] materials = new Material[renderer.sharedMaterials.Length + 1];
System.Array.Copy(renderer.sharedMaterials, materials, renderer.sharedMaterials.Length);
materials[materials.Length - 1] = anyMaterial;
renderer.sharedMaterials = materials;
Would anyone tell me about good way to it?
Answer by Meishin · Aug 08, 2019 at 05:21 AM
Hello @edo_m18,
Even for PC/MAC, you should avoid using several materials since it requires additional rendering passes, unless you use a specific shader (but in that case you would generally set the textures in the shader options directly, resulting in a single material).
The best way would be:
1- If your materials are always supposed to be together, blend your textures in a 3DModeling/Texture tool so as to create a unique material in the end
2- If you want to change part of the texture independantly, use a specific shader (if you don't want to create one, you can try Alloy "decals" for example)
@$$anonymous$$eishin Thank you for replying! I'm planning to create a UnityAsset. So I can't know that how to be used my asset by my users. Please see below link that shows you what I want to create.
https://twitter.com/edo_m18/status/1158521519309381632
I want to project any texture to targets that using my asset. $$anonymous$$y asset will create a material for projection and assign to the target. So I can't create a new shader for the users.
Do you have any idea for it?
I really want to know that how about I can create an asset like the video. $$anonymous$$y decision is what assign my material to the target. It is easy way to show a projection texture that is my decision. But it is not necessary to create if any idea is.
@edo_m18 Have you checked/Are you using projector in standard assets ? https://docs.unity3d.com/$$anonymous$$anual/class-Projector.html
No, the projector system is $$anonymous$$e. I created original projector.
Your answer
Follow this Question
Related Questions
Changing two different objects renderer colour 1 Answer
How do I add a material to all of a parent's children and have the changes persist (ie w/ script)? 0 Answers
Trying to make a side scroller. I'm following a tutorial and getting this error. 1 Answer
appear/disappear gameobject 3 Answers
SetFloat doesn't work 1 Answer