3

There's plenty of tutorials which explain how to add and manage image objects. But what if I want to add simple rectangle with plain white color? May I do it similar to adding 3D objects? I see no rectangle option under 2D Object in GameObject menu.

I know that I may do it by script, but isn't there any simpler solution? Or maybe I should use 3D Object Cube instead?

Martin
  • 22,212
  • 11
  • 70
  • 132
Lukis
  • 652
  • 7
  • 20

1 Answers1

2

For a rectangle (ie a 2D cuboid) you add a 3D object that is a Quad which is a 3D object with a size of 0 in one plane, in effect making it a 2D sheet.

See also: http://docs.unity3d.com/Manual/PrimitiveObjects.html

Quads are most often used as backdrops to 2D games. Once you have the quad you can then change its material properties to set it as a single plain colour.

Martin
  • 22,212
  • 11
  • 70
  • 132
  • Yes! That's what I've been looking for! But It looks like I need to add a light source to camera for such objects. All image type objects are natural bright, instead of Quad objects, which are dimmed a lot. Is it a bug or a feature? – Lukis Jul 18 '15 at 09:07
  • no, you can use absolute lighting by selecting the Quad object, goto the **material / mesh renderer --> shader --> unlit** and there will be a number of choices, typically you can choose "texture" or for your question you can use ***"color"*** which will display the quad as an unlit (but displayed at absolute intensity) colour value. @Lukis – Martin Jul 18 '15 at 09:09
  • Yay!! It works like a charm! So every instance of material is constant? If i would like to modify "whiteMaterial" (for example), do I have to duplicate it and change the single parameter to value I want? There is no possibility to change it's value for particular object which uses the material? – Lukis Jul 18 '15 at 09:33
  • As far as I know, you need a set of different static materials, for different textures and colours, but if you're looking at plain colour objects then you can use the **mesh renderer --> shader --> unlit --> color** and then just select the colour that you want the object to be. This can then easily be changed via code, too. @Lukis – Martin Jul 18 '15 at 09:38
  • Unfortunately "shader" option is... shaded unless I drop any material from assets there. Then I may edit, but it edits the material which causes that every instance of this material will be changed. – Lukis Jul 18 '15 at 09:50
  • hmmm, I have a Quad in one game I am constructing and selecting Shader->unlit->color removes the texture and replaces it with a solid colour value. This is just a quad object not a prefab or anything. I'm not sure what else to recommend to you, try here: http://unity3d.com/learn/tutorials/modules/beginner/graphics @Lukis – Martin Jul 18 '15 at 10:05
  • That's ok. You helped me a lot! – Lukis Jul 18 '15 at 18:51