Mouse Coordinates to world coordinates - (Custom GUI)

Hello, so I will show the code here then explain what I’m trying to do.

Code

    void MouseBoxCheck1(){
        if (Input.mousePresent) {
            if (Input.mousePosition.x > 634/*  Left  */) {
                if (Input.mousePosition.x < 804/*  Right  */) {
                    if (Input.mousePosition.y < 470/*  Top  */) {
                        if (Input.mousePosition.y > 402/*  Bottom  */){
                           //Doing Stuff here
                      }
                    }
                }
            }
        }
    }

Right now you have seen what I am doing you can probably tell I’m trying to check if the mouse is in a certain area and if so it does something, however there is a problem with this, as you may be aware the mouse’s coordinates change according to the size of the display area (I found this out when it worked in the editor but not the built application).

What I wish to do is use the world coordinates instead of the mouse ones so that I can use it on any size of display area, so if anyone can offer any advice that would be great. (If you can give examples relative to my code with any answers that would be great, thanks in advance!)

This?

Probably, I have been on that page before but I have no idea how to use it,I haven’t really done much scripting before and I have no idea how to use this in the context that I have. Could you create an example of it for use in my code?

First and foremost: For what purpose are you trying to reinvent what is already a solved problem with the new Unity UI?

Secondly:

Vector3 worldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

Well to be honest I didn’t really know how to use the UI system, I’m kinda new to unity, I mean I have had it for like over a year but I have only dabbled in it now and then and in that time I have had no use for it. So with not knowing how to use it I decided to use a system I knew how to use, that system involved keyboard controls increasing and decreasing ints to disable or enable gameobjects to create a UI,l but then of course I got more ambitious and decided I wanted to make mouse controls, so after working so hard on this UI I created myself I didn’t want to replace it so, I have still not looked into the UI apart from going through the manual on it.

Oh and thanks to both of you!