I want to resize a button while it’s being pressed. At the moment I have a style with no image as background (_style.normal.background = null) and Buttons are being drawn using some images and that style. I would like to define a size of the buttons being displayed for the same layer but in the active state instead of normal and I have no idea how to do it.
code:
public class Buildings : MainSubPanel {
private Rect[] _boxes;
private GUIStyle _style;
private Texture2D[] _icons;
public Buildings(Swapper swapper, Texture2D[] icons) : base(swapper){
int i = 0;
int n = 0;
int shift = 10;
_icons = icons;
_boxes = new Rect[12];
_style = new GUIStyle();
_style.normal.background = null;
while(i < 3){
while(n < 4){
_boxes[i*4+n] = new Rect(15+shift+shift*n+50*n, 15+shift+shift*i+i*50, 50, 50);
++n;
}
n = 0;
++i;
}
}
public override void draw(){
int i = 0;
while(i<_icons.Length){
if(GUI.Button(_boxes<em>, _icons*, _style)){*</em>
* swapper.swap(i);
_ }*
* i++;*
* }*
* }*
}
A grid of buttons actually. The difference being that, when you clic one, it stays activated and deactive the previous one. For example, if you have a selection grid with those elements : "Banana", "Apple", "Strawberry", you can choose which one you're going to eat (only one mind you !). For the script part, check out the manual.
– Subhuman