playMaker

Author Topic: Button with custom shape (SOLVED)  (Read 438 times)

MichaelPatriot21

  • Playmaker Newbie
  • *
  • Posts: 23
    • View Profile
Button with custom shape (SOLVED)
« 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?
« Last Edit: January 28, 2019, 02:50:15 PM by MichaelPatriot21 »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3632
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Button with custom shape
« Reply #1 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.

MichaelPatriot21

  • Playmaker Newbie
  • *
  • Posts: 23
    • View Profile
Re: Button with custom shape
« Reply #2 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?

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3632
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Button with custom shape
« Reply #3 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!
« Last Edit: January 28, 2019, 02:08:16 PM by Alex Chouls »

MichaelPatriot21

  • Playmaker Newbie
  • *
  • Posts: 23
    • View Profile
Re: Button with custom shape
« Reply #4 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.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14564
  • Official Playmaker Support
    • View Profile
Re: Button with custom shape (SOLVED)
« Reply #5 on: January 29, 2019, 02:13:45 AM »
Hi,

 cool!

 I made a custom action for this that you can get on the Ecosystem, the action is called uGuiSetImageAlphaTestThreshold

Bye,

 Jean

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3632
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Button with custom shape (SOLVED)
« Reply #6 on: January 30, 2019, 01:11:09 PM »
Thanks, Jean! I added this info to the step-by-step page.