- Home /
 
OnGUI Button
Hi everyone, I am basically trying to make a phone screen resolution independent gui button.This is what I have so far, it creates a button and makes it resolution independent:
 function OnGUI (){
 GUI.Button(Rect(Screen.width * (0.3f/6.55f),Screen.height * (0.3f/6.3f),Screen.width * (1.9f/6.55f), Screen.height * (1.3f/6.3f));
 }
 
               What I want is for the button to be transparent. I also am looking for a way to tap this button on a phone and for it to carry out an action. I would be really greatful if you guys could help me. Thanks :D
Answer by $$anonymous$$ · Feb 24, 2013 at 07:49 PM
if you want the button to be transparent, you will have a create your own GUI skin look here for a tutorial on that. And as for making the button do something:
 function OnGUI ()
 {
     if( GUI.Button(Rect(Screen.width * (0.3f/6.55f),Screen.height * (0.3f/6.3f),Screen.width * (1.9f/6.55f), Screen.height * (1.3f/6.3f))))
     {
         //do somthing
     }
 }
 
               look here for anything else that you need to know about gui.
oops, im sorry i never tested it here is the correct way:
 function OnGUI ()
 {
     if( GUI.Button(Rect(Screen.width * (0.3f/6.55f),Screen.height * (0.3f/6.3f),Screen.width * (1.9f/6.55f), Screen.height * (1.3f/6.3f)), ""))
     {
        //do somthing
     }
 }
                 Your answer
 
             Follow this Question
Related Questions
Rescale GUITexture Android/IOS 1 Answer
How to display a set of guiText OnGUI 0 Answers
OnGUI() Resources 1 Answer
[Solved] GUI Error? 1 Answer
Ignore Input.GetMouseButtonUp for clicks that were used on GUI elements 2 Answers