//button sizes can be set in this method private static Vector2 SetSize(SizeDef size) { Vector2 finalSize; switch (size) { case SizeDef.small: finalSize = new Vector2(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT); break; case SizeDef.medium: finalSize = new Vector2(MEDIUM_BUTTON_WIDTH, MEDIUM_BUTTON_HEIGHT); break; case SizeDef.big: finalSize = new Vector2(LARGE_BUTTON_WIDTH, LARGE_BUTTON_HEIGHT); break; default: Debug.LogError("Unknown button size, defaults to medium."); finalSize = new Vector2(MEDIUM_BUTTON_WIDTH, MEDIUM_BUTTON_HEIGHT); break; } return(finalSize); }
//specify position manually, choose size from the list public GUIParams(float posX, float posY, SizeDef size, string guiText) { text = guiText; Vector2 buttonSize = SetSize(size); width = buttonSize.x; height = buttonSize.y; x = posX; y = posY; fontSize = width / 6; }
//choose size and position from the list public GUIParams(PositionDef position, SizeDef size, string guiText) { text = guiText; Vector2 buttonSize = SetSize(size); width = buttonSize.x; height = buttonSize.y; Vector2 buttonPos = SetPosition(position, width, height); x = buttonPos.x; y = buttonPos.y; fontSize = width / 6; }
//choose size from the list, default position public GUIParams(SizeDef size, string guiText) { text = guiText; Vector2 buttonSize = SetSize(size); width = buttonSize.x; height = buttonSize.y; //position defaults to middle Vector2 buttonPos = SetPosition(PositionDef.middle, width, height); x = buttonPos.x; y = buttonPos.y; fontSize = width / 6; }
//choose size and position from the list public GUIParams(PositionDef position, SizeDef size, string guiText) { text = guiText; Vector2 buttonSize = SetSize(size); width = buttonSize.x; height = buttonSize.y; Vector2 buttonPos = SetPosition(position, width, height); x = buttonPos.x; y = buttonPos.y; fontSize = width/6; }
//choose size from the list, default position public GUIParams(SizeDef size, string guiText) { text = guiText; Vector2 buttonSize = SetSize(size); width = buttonSize.x; height = buttonSize.y; //position defaults to middle Vector2 buttonPos = SetPosition(PositionDef.middle, width, height); x = buttonPos.x; y = buttonPos.y; fontSize = width/6; }
//specify position manually, choose size from the list public GUIParams(float posX, float posY, SizeDef size, string guiText) { text = guiText; Vector2 buttonSize = SetSize(size); width = buttonSize.x; height = buttonSize.y; x = posX; y = posY; fontSize = width/6; }
//button sizes can be set in this method private static Vector2 SetSize(SizeDef size) { Vector2 finalSize; switch (size) { case SizeDef.small: finalSize = new Vector2(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT); break; case SizeDef.medium: finalSize = new Vector2(MEDIUM_BUTTON_WIDTH, MEDIUM_BUTTON_HEIGHT); break; case SizeDef.big: finalSize = new Vector2(LARGE_BUTTON_WIDTH, LARGE_BUTTON_HEIGHT); break; default: Debug.LogError("Unknown button size, defaults to medium."); finalSize = new Vector2(MEDIUM_BUTTON_WIDTH, MEDIUM_BUTTON_HEIGHT); break; } return finalSize; }