- Home /
Make Object next to GUI.Button
Hey,
I found following Circular Progress Bar: http://forum.unity3d.com/threads/124732-An-alternative-circular-progress-bar
So now I wanted the progress bar, which is a game object, to be next to my GUI Buttons. So I tried to convert the GUI Button position to a world space position but it didn't really work out. What I tried is:
Vector2 GUIPosition = new Vector2(ButtonPosition.x,ButtonPosition.y); Vector2 ScreenPosition = GUIUtility.GUIToScreenPoint(GUIPosition); progressBar.transform.position = myCamera.ScreenToWorldPoint(ScreenPosition);
I also tried to directly translate the GUIPosition into the world position but that also didn't solve my problem.
So however I try it the progressBar ends up somewhere close to the Camera (as I can see in the scene view), but it won't show up in the game view.
Would be great if anybody has any suggestion on how to solve this.
Decide where you want your gameobject on your screen. I mean the X and Y position.
Then reposition your gameobject at a position as follows:
var position = camera.ScreenToWorldPoint (Vector3 (x_position,y_position,camera.nearClipPlane));
The gameobject (progress bar, here) can be positioned right in front of the camera.. and can be used as an illusion that is in fact on the GUI.
PS: a tip, scale your gameobject so that it doesn't fill you whole screen..
There are two conversions here. You need to convert GUI to Screen, then Screen to World. Here is a recent question where I deal with both conversions:
http://answers.unity3d.com/questions/696661/converting-world-coordinates-to-screen-coordinates.html
Your answer
![](https://koobas.hobune.stream/wayback/20220613143848im_/https://answers.unity.com/themes/thub/images/avi.jpg)