I’ve made it so that I can instantiate a prefab of an EZGUI button. I can also change the values for “scriptWithMethodToInvoke” and “methodToInvoke” on the prefab.
Here’s the problem: I can’t change the texture programmatically. I tried using the UIButton method called SetTexture(), but I didn’t realize that it can only work with non-managed sprites. I’m thinking that I need to use the method SetCurFrame, or maybe setOffset, but I have no idea how to use them. Can anyone help me out?
not a 100%. I asked Brady this a while back. I checked my email but no luck. I think you are looking for setState() tho. There you should be able to set the state of the button and thus the frame of that state.
I had used Copy() method to change texture.
Here is some code that I made.
public static class CButtonImageChanger
{
public static void copy(UIButton from, UIButton to)
{
// Before I copy it, I had make appear each buttons.
// If the button is hidden, You will get some errors when running in Web Player.
// However in the editor, there is no errors.
// Show a button.
bool hidden_from = from.IsHidden();
from.Hide(false);
// Show a button.
bool hidden_to = to.IsHidden();
to.Hide(false);
// Copy from → to.
to.Copy(from);
// Restore.
from.Hide(hidden_from);
to.Hide(hidden_to);
}
}