- Home /
GUITexture not corresponding with position
Hello guys!
I have a slight but annoying issue I hope you can help me with. Basically I am trying to make some GUITexture-buttons for my game, to appear at the end of a round - the standard "play again" v "return to menu" stuff. The buttons work, I guess, but the area in which I need to click is not on the texture itself, but completely to the left of it! Even stranger, the more I move the GUITexture to the left, the more 'accurate' it becomes.
my code is a very simple (pseudocode:)
function OnMouseUp(){
//return to menu
}
...and the GUIbuttons with the same code work in the main menu, just not in my game-scene. Can anyone help?
Seeing the On$$anonymous$$ouseUp function doesn't help much when the problem clearly is that it's not getting called when it should. We'd have to see how your buttons are made to be able to help.
Hello, thanks for replying. $$anonymous$$y question was blocked the first time when I just referenced the On$$anonymous$$ouseUp in passing, so I thought it might be against the rules to not have it in code.
I import the texture. With that texture highlighted I create a new guiTexture. I place it in the scene, attach the script, and turn visibility off. When the player dies the visibility is turned back on, and the button's clickable area is outside the button. I've tried a myriad of positions, and also without the visibility-functionality, it still doesn't work. Is that what you meant?
PS: It's a 2D game, dunno if that has any meaning, but as I said, the buttons work fine in the other scene, so I guess not, but there it is.
Answer by Warbeard · Dec 12, 2014 at 07:29 AM
I think I got it fixed - the issue was, I think, that the camera for some reason had its viewport width set to 0.7. This was not so in the menu scene where the buttons did work, and after correcting it the buttons seem to be working as intended! Hope this helps someone else out there!
Your answer
Follow this Question
Related Questions
Overlapping GUITexture UI Buttons 2 Answers
Strange GUITexture Bug?? 0 Answers
Can I assign controls to GUITexture button? 1 Answer
How to access other Scripts and Components 1 Answer
Shoot when GUI is pressed? 0 Answers