x


Before updating to Windows 10 you may need to return your Pro license. More information here

Rect.contains to replace gui

How do you use Rect.contains on iphone or android to replace gui?

I'm a huge noob when it comes to it and I can't even figure out how to show the rect visually so I know where it is.

Any examples will help

Thanks

more ▼

asked Sep 12, 2011 at 09:40 PM

avatar image

FTheCloud
775 46 39 69

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

I'm completely stupid about iPhone or Android, but already used Rect.Contains in a similar application. Supposing GUI works in mobile devices, I would use GUI.Box just to see the sensible areas, then rename or delete the OnGUI function when everything was ok - something like this:

// define the rects var r1 = Rect(10,10,200,80); // left, top, width, height var r2 = Rect(10,100,100,100); var r3 = Rect(120,100,100,100);

function OnGUI(){ // use this to see the areas covered GUI.Box(r1, "area1"); // you can modify the rects until GUI.Box(r2, "area2"); // they cover the desired areas, then GUI.Box(r3, "area3"); // rename the function to deactivate it }

// Check the areas with "rN.Contains" when the screen is touched - again, I'm // a total void about touches; please fix any stupid thing I may have done // in this touch stuff function Update(){ if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began){ var pos = Input.GetTouch(0).position; if (r1.Contains(pos)){ // area 1 touched } if (r2.Contains(pos)){ // area 2 touched } if (r3.Contains(pos)){ // area 3 touched } } }

more ▼

answered Sep 13, 2011 at 01:17 PM

avatar image

aldonaletto
61.6k 57 213 361

AMAZING

Sep 13, 2011 at 06:51 PM FTheCloud
(comments are locked)
10|3000 characters needed characters left

Simple the greate

more ▼

answered Jun 10, 2013 at 06:35 AM

avatar image

ALI_Naeem
0 1 2 4

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x6710
x1509
x178

asked: Sep 12, 2011 at 09:40 PM

Seen: 2789 times

Last Updated: Jun 10, 2013 at 06:35 AM