Hint: Always initialize textures before assignment [OK]
Common Mistakes:
Forgetting to create or load the texture
Assuming GetComponent works without gameObject
Thinking mainTexture is read-only
5. You want to create a material that uses a texture only on the top face of a cube in Unity. Which approach is best?
hard
A. Create multiple materials and assign one to the whole cube
B. Use a custom shader with UV mapping to apply texture only on the top face
C. Assign the texture to the material's mainTexture and it will auto-apply to top face
D. Change the cube's color to match the texture color on the top face
Solution
Step 1: Understand texture application on specific faces
Unity materials apply textures based on UV mapping. To target only the top face, UVs or shader logic must isolate that face.
Step 2: Evaluate options for selective texturing
Assigning texture to mainTexture applies it to all faces. Multiple materials can assign different materials per face but require mesh setup. Changing color won't apply texture.
Step 3: Choose best approach
Using a custom shader with UV mapping allows precise control to show texture only on the top face.
Final Answer:
Use a custom shader with UV mapping to apply texture only on the top face -> Option B