So, here is what I am trying to do in Unity 5 (using C#). I want to draw a a 2D circle at the background of a 3D scene and apply a texture/image to fill it.

Just like it would be if the circle was in the GUI, but now being always behind everything else instead of always in front (think of a moon in the sky of a piloting game, or a distant planet in a space game, etc).

What would be the fastest way to draw such a circle and, of course, update its radius depending on the camera distance? Of course, I don't want to use a sphere, I want to learn how to that with a simple circle that gets bigger or smaller depending on the distance of the viewer.

  • \$\begingroup\$ Did you try to setting radius according to the distance between camera and moon. (Vector3.distance)? \$\endgroup\$ Commented Dec 14, 2015 at 19:29
  • \$\begingroup\$ You may want to use OnPreRender() to immediately draw your (masked) texture. I think that will achieve the effect you want. Then the scene will draw on top. However the best idea might be to draw the whatever to a texture and that texture is then used as the skybox. \$\endgroup\$ Commented Jan 27, 2016 at 21:03
  • \$\begingroup\$ @Draco18s the first suggestions seems promising. The problem with your second is that it would become impossible to rescale the circle without scaling all things that are draw in the skybox, right? Or are you suggesting run-time redrawing the skybox's texture? \$\endgroup\$
    – Louis15
    Commented Jan 29, 2016 at 1:25
  • \$\begingroup\$ @Louis15 No no, the skybox is a dynamic texture (a render texture). It gets redrawn every frame. \$\endgroup\$ Commented Jan 29, 2016 at 15:07

2 Answers 2


Ok, so just of the top of my head your going to want to make a new circle(2d) and apply a texture to this then write something along these lines (and attach it to the object)

Pseudo code:

private gameobject player
private float scale;

face the player (using transform.lookat(player))
float distance = vector3.distance(transfrom.position,player.transform.position);
transform.scale = distance / scale;

The scale in this case changes as the player gets closer or further away using the global scale variable to change the sensitivity of it. Obviously i haven't tested it but in 5 min this would be my initial solution.

If you wanted to make it more efficient, then only face the player every few updates, possibly only make it call recursively every few seconds (depending how far away the player is/ how fast the player is).

An answer is better than none... :)

  • \$\begingroup\$ Many thanks. What you are suggesting is the creation of a circle sprite that could be just put at the very far background and updated in terms of scale and rotation as needed? \$\endgroup\$
    – Louis15
    Commented Jan 29, 2016 at 1:28
  • \$\begingroup\$ yep, fairly simple. Alternatively you could have it be a fixed distance away from the camera but then you might run into clipping problems as you move around... \$\endgroup\$ Commented Jan 29, 2016 at 18:29

You probably need a skybox or a skydome. A skybox is a box around the camera, and is always centered around it. Basically a model, wich isn't get transformed by the view matrix.

  • \$\begingroup\$ I know skyboxes, but how exactly that could help me doing what I've asked, i.e. having a circle at the background whose size can be updated as described? \$\endgroup\$
    – Louis15
    Commented Jan 29, 2016 at 1:26
  • \$\begingroup\$ Dinamically generated textures? \$\endgroup\$
    – Bálint
    Commented Jan 29, 2016 at 6:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .