Author Topic: *SOLVED* Modifying Button Script  (Read 2153 times)


  • Guest
*SOLVED* Modifying Button Script
« on: June 12, 2012, 02:04:51 PM »
I found another solution to this problem..

I am trying to make custom button scripts from the UImageButton script.
However, when I duplicate and rename the script, the Normal, Hover, and
Press strings are no longer drop down options but become text entry lines.
I would like to know where those are set up so I can make them show
the drop downs like they do in the original script.

I found the UIImageButtonInspector script where it assigns the sprites
to the fields, but I am not sure if modifying it to work with my new and
renamed scripts is the best way to go. I was thinking of making a few
new UIImageButton references named mButton1... mButton2, so I
can refer to my new scripts. But, I am not sure if I am trying to do
too much.

I want to make custom button scripts for each button to do something
specific when they are pressed. Am I going about this the wrong way.
« Last Edit: June 12, 2012, 02:46:27 PM by Ingot »


  • Guest
Re: *SOLVED* Modifying Button Script
« Reply #1 on: June 12, 2012, 03:38:39 PM »
What type of something specific are you talking about? Because you can always create a new script which implements the OnPress(bool) and do what you wish in that script and leave UIImageButton to handle the switching of the sprite as it does now.


  • Guest
Re: *SOLVED* Modifying Button Script
« Reply #2 on: June 12, 2012, 07:32:49 PM »
I wanted the button to switch images and also tell another script to do an action.
I was going about it the wrong way thinking that I had to modify the UIImageButton
script to do that. I simply attached another script that contained an OnClick method
that takes care of it. I am also using OnMouseDown and OnMouseUp methods to
manually control the image switching since I want some of the buttons to be toggles
and not return to the default image when the mouse is released. So, I did modify the
UIImage script to not change on hover and I moved the OnPress out to the extra
script using OnClick and OnMouse methods. I may use the OnPress method if there
are any considerations that I should be aware of.

Thank you for the prompt and concise response.