- Home /
GUI Texture fixed on Object
Good evening,
What it should be in the end is a Texture which changes with the time. So a progress bar projected to the ground for the player to see. Also my camera just rotates, the position of the player will not change.
With that code the texture rotates with the camera:
the texture on the floor
the texture rotates on the floor
Basically I want the Texture stay at this point with the rotation clamped. So when the player moves the camera the Texture stays the exact position and rotation it has in the first picture. Maybe I just think to complicated... Please help me out here.
Here is my Code:
#pragma strict
var toTrack : Transform;
var tex : Texture;
var above : float = 0; // How much offset from center of toTrack;
var X : float;
var Y : float;
private var rect : Rect;
function Start () {
rect.width = tex.width;
rect.height = tex.height;
}
function OnGUI() {
var v3Pos = toTrack.position;
v3Pos.y += above;
v3Pos = Camera.main.WorldToScreenPoint(v3Pos);
v3Pos.y = Screen.height - v3Pos.y; // Convert screen to GUI
rect.x = v3Pos.x - tex.width / 2.0; // Offset to anchor in the middle
rect.y = v3Pos.y - tex.height / 2.0;
GUI.DrawTexture(rect, tex);
}
Thanks for your attention and answers, best regards
Nitrosocke - Dennis
Answer by calmcarrots · Aug 07, 2014 at 11:39 PM
Dont use a GUITexture. That stuff is for screen HUD or something similar. Use a 3D text for this http://docs.unity3d.com/Manual/class-TextMesh.html
This might also solve a future question that I know you will have
http://wiki.unity3d.com/index.php?title=3DText
Good luck
I forgot to mention that i want it to change. The Texture was just a dummy. So what I want is that the progress bar, which fills over time is projected to the floor. I'll add that to my question.
Your answer
Follow this Question
Related Questions
How to display textures that are in an array? 1 Answer
Masking GUI Textures 2 Answers
scale textures using scrollbars that show/enable when texture is clicked on 0 Answers
Menu material error 1 Answer