- Home /
GUI.Button child of the camera .
Hello ,
this is my script :
{
private GUISkin skin;
void Start()
{
// Load a skin for the buttons
skin = Resources.Load("GUISkin3") as GUISkin;
}
void OnGUI()
{
const int buttonWidth = 300;
const int buttonHeight = 80;
// Set the skin to use
GUI.skin = skin;
if (
GUI.Button(
// Center in X, 1/3 of the height in Y
new Rect(
Screen.width / 2 - (buttonWidth / 2),
(2 * Screen.height / 5) - (buttonHeight / 2),
buttonWidth,
buttonHeight
),
"New Game"
)
)
{
// Reload the level
}
and i want to move the GUI.Button with the camera , i mean when the camera transform position, the GUI.Button follow the camera .. and thanks
Your question doesn't make sense to me unless you have two cameras. GUI.Buttion() calls specify positions in screen coordinates and will remain at the same position on the screen. Transforms use world coordinates. It is possible to map a GUI to a world coordinate, but you talk about "follow the Camera," which doesn't make sense.
Your answer
Follow this Question
Related Questions
Transform.LookAt - wrong vector 4 Answers
Why is my Camera rotation tilted after parenting it to head? 1 Answer
getting the position of player for the minimap to follow 1 Answer
Setting a cube to be exactly size of intersecting camera view plane 1 Answer
How do I set a child object to not rotate if the parent WILL be rotating? 1 Answer