Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: MichaelPatriot21 on January 25, 2019, 11:41:53 AM

Title: Button with custom shape (SOLVED)
Post by: MichaelPatriot21 on January 25, 2019, 11:41:53 AM
I'm making a hidden object scene, where you click on items to find them. However, the buttons are all square, which goes far beyond where the object is. It makes it to where, to find the object, the player just has to click within the general vicinity of the object. How do I set a button to only cover an image?
Title: Re: Button with custom shape
Post by: Alex Chouls on January 27, 2019, 11:13:35 AM
You should be able to use this property:
https://docs.unity3d.com/ScriptReference/UI.Image-alphaHitTestMinimumThreshold.html

Use Set Property on the Image to set the alpha threshold considered a hit.
You'll also need to set the sprite to Read/Write enabled in the advanced Texture Import Settings and disable atlassing for the sprite.
Title: Re: Button with custom shape
Post by: MichaelPatriot21 on January 28, 2019, 12:03:33 PM
Sorry, but I'm not understanding this. Is there a simpler way? Or perhaps more step-by-step instructions?
Title: Re: Button with custom shape
Post by: Alex Chouls on January 28, 2019, 02:05:08 PM
I made a quick step-by-step here:
https://hutonggames.fogbugz.com/f/page?W1706

We're also working on new UI samples, so I'll add this as a sample.

EDIT: There may also be a simpler way to do this, but this is what I found in my research!
Title: Re: Button with custom shape
Post by: MichaelPatriot21 on January 28, 2019, 02:49:25 PM
Thank you so much, I was looking all over for this. Was trying everything, including scripting tutorials. I had no idea you could drag components into the FSM.
Title: Re: Button with custom shape (SOLVED)
Post by: jeanfabre on January 29, 2019, 02:13:45 AM
Hi,

 cool!

 I made a custom action for this that you can get on the Ecosystem (https://hutonggames.fogbugz.com/?W1181), the action is called uGuiSetImageAlphaTestThreshold

Bye,

 Jean
Title: Re: Button with custom shape (SOLVED)
Post by: Alex Chouls on January 30, 2019, 01:11:09 PM
Thanks, Jean! I added this info to the step-by-step page.