Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: CBYum on August 19, 2014, 05:28:32 AM

Title: How to set up an Image Button
Post by: CBYum on August 19, 2014, 05:28:32 AM
I must be missing something obvious but I just can't find how to set up an image button. From the docs you used to have to use a UIImageButton but when I add one it says that its functionality has been added to UIButton. But I don't see anything that could let me set a list of images for the button states. It only has a range of colors for the different states.

I create a UITexture and add a UIButton component to it. I see a Tween Target but if I set it with something that just seems to get color changes. I'm using 3.7.0 (updated today)

Any chance the docs could be updated?

Ta
Title: Re: How to set up an Image Button
Post by: ArenMook on August 19, 2014, 11:36:06 AM
UITexture is not compatible with a UIButton. UIButton component works by swapping sprites. UITexture works with textures, not sprites. You need to use a UISprite instead of a UITexture. What docs are you referring to?
Title: Re: How to set up an Image Button
Post by: CBYum on August 20, 2014, 06:58:18 AM
I did try it based on a sprite and didn't see any other new options appear other than pixel snap.

Just to confirm, I'm after a button that changes the image on it when you press it.

The docs I was looking at were: http://www.tasharen.com/forum/index.php?topic=6708.0
Title: Re: How to set up an Image Button
Post by: ArenMook on August 20, 2014, 04:20:09 PM
I am not sure what you're looking at, but when you choose a sprite, you get more options:
Title: Re: How to set up an Image Button
Post by: CBYum on August 21, 2014, 02:31:15 AM
Hmmm, that's exactly what I was hoping to see! I just get the pixel snap option and nothing else.

Just tried it with a fresh scene. I created a sprite using your menu. I add a UIButton to it using your menu. And the result is in the picture. I tried creating an empty object, adding a UIButton and then creating a sprite separately and using it as the target for the button but this made no difference.

I'm using Unity 4.5.0 pro.

... some time later...

Ah ok I hadn't selected an atlas and so it doesn't show the options until I do. Problem solved.

Would be good if that shot you included here was added to the docs as they shows a sprite example without those options visible.

Thanks