playMaker

Author Topic: Detect touch GuiTexture  (Read 15286 times)

tofusoup

  • Playmaker Newbie
  • *
  • Posts: 30
Detect touch GuiTexture
« on: June 11, 2011, 08:09:40 PM »
Is there a way to detect if I touch GuiTexture?  I can get mouse pick to work with 3d game objects, but now I'm messing around with it.  It be nice to have something similar to mouse down or mouse up that can be used on iOS.

Any tips?

I don't see anywhere where there is a "guiTexture.HitTest"

I was mostly reading this -> http://forum.unity3d.com/threads/30562-Detecting-touch-on-a-guiTexture

thanks.

giyomu

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 108
    • blog
Re: Detect touch GuiTexture
« Reply #1 on: June 11, 2011, 09:06:58 PM »
you may want create an action maybe if you do not find something with action already set to get you there
i can eventually do a quick one if scripting action is not your cup of tea tho, i never look at it really about guitexture touch so before have to be sure it is not avalaible already lost in the pile of action already done ^^

tobbeo

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 186
Re: Detect touch GuiTexture
« Reply #2 on: June 11, 2011, 09:12:15 PM »
What about placing an invisible gameobject parented to the camera where your IOS GUI button is?

tofusoup

  • Playmaker Newbie
  • *
  • Posts: 30
Re: Detect touch GuiTexture
« Reply #3 on: June 11, 2011, 10:52:29 PM »
I can place an invisible game object near it.  When I parent it the object disappears though.  Seems like it should be something that comes with PM.

I'm not good at writing scripts heh.

I can always use a GUI button for now or place an object near it.

any actual way?

tofusoup

  • Playmaker Newbie
  • *
  • Posts: 30
Re: Detect touch GuiTexture
« Reply #4 on: June 11, 2011, 11:52:12 PM »
Yea if someone can write a script that be awesome.  I rather use GuiTexture.

For the community!  Or I pitch in some $$

But first someone check if it's doable easily in PM

thanks.

tobbeo

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 186
Re: Detect touch GuiTexture
« Reply #5 on: June 12, 2011, 02:00:11 AM »
I can place an invisible game object near it.  When I parent it the object disappears though.  Seems like it should be something that comes with PM.

I'm not good at writing scripts heh.

I can always use a GUI button for now or place an object near it.

any actual way?

The object shouldn't disappear when you parent it to the camera. Parenting can be done without scripting. Just drag the object on top of the camera in the scene list of your objects. My philosophy is to do whatever it takes to get the job done. Sure, putting in a request is great and will help but if you need to get it done now using an object with a trigger bounding box is really easy. I just tested it on my side.

On the same topic, my GUI is almost completely based on sprites on planes parented on the camera. I find it way more flexible to do fun stuff with the GUI since it's actually in 3D and I see very little downsides.

tofusoup

  • Playmaker Newbie
  • *
  • Posts: 30
Re: Detect touch GuiTexture
« Reply #6 on: June 12, 2011, 03:53:31 AM »
I was trying to parent the 3d object (box) to the guiTexture when it disappeared.  Yea to camera works.  I agree, sure to get a workaround but this is what PM is for and it's something everyone can use.

For the most part, yes, using 3d objects will work, but isn't the issue with building out your UI so it's scalable for not just iOS?  Not to mention the different resolutions of the devices.

I guess you can get screen width and height to know how big to scale up the 3d UI?

It just seems you can always have a workaround but something like this should just work.

tobbeo

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 186
Re: Detect touch GuiTexture
« Reply #7 on: June 12, 2011, 05:24:30 AM »
I was trying to parent the 3d object (box) to the guiTexture when it disappeared.  Yea to camera works.  I agree, sure to get a workaround but this is what PM is for and it's something everyone can use.

For the most part, yes, using 3d objects will work, but isn't the issue with building out your UI so it's scalable for not just iOS?  Not to mention the different resolutions of the devices.

I guess you can get screen width and height to know how big to scale up the 3d UI?

It just seems you can always have a workaround but something like this should just work.

I don't really agree with the way you express yourself in the part I put in bold, that things like this should just work. I'm not saying it would be a bad action to have, it would be, but seeing as there is an easy work around I feel that actions that does things not possible in PM yet is more important. It was a suggestion to help you out. You've made your request and I am sure Alex has put it on his todo list and will weigh the priorities of what needs to get done first. Also, something to keep in mind is that a 1.0 (or in this case we are now at 1.1) version of any software isn't going to be able to do everything.

In my own opinion, Unity's GUI system is very limited and outside of printing text I wouldn't really use it. But that's completely up to you of course. I would personally really love to see more custom actions for EzGUI. Cheap plugin for Unity that you can use to set up very fancy GUI systems. Of course right now you need to script to use it so actions to access those functions would be great IMO.

Anyway, you've made your voice heard, I gave you a work-around until Playmaker will have that custom action and it's up to you to decide where to go from here! Either wait for the action or try to work around it!

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Detect touch GuiTexture
« Reply #8 on: June 12, 2011, 10:20:33 AM »
Hi guys, I posted a GUI Element Hit Test action here: http://hutonggames.com/playmakerforum/index.php?topic=325.0

You should be able to combine this with GetTouchInfo to get the screen point for the hit test, but I only tested with Get Mouse X/Y.

Threw this together pretty quickly, so post any bugs you find!

tofusoup

  • Playmaker Newbie
  • *
  • Posts: 30
Re: Detect touch GuiTexture
« Reply #9 on: June 12, 2011, 12:27:31 PM »
First, thank you Alex and your team! I'll check it out 

I didn't mean to come off like a Jerk.  Having EzGUI actions would be awesome, but just getting the rest of Unity functions as actions is even better, imo.

Thanks for the suggestions and help.  I will use a mix of both.