public IGuiButton(IGuiCommand command, float x, float y) : base(command) { // Create game object from prefab GuiObject = (GameObject) Object.Instantiate(Resources.Load("BlankButton")); ButtonObject = GuiObject.GetComponent<Button>(); Transform = GuiObject.GetComponent<RectTransform>(); // Add destroy script to object if (ButtonObject.gameObject.GetComponent<DestroyGuiScript>() == null) ButtonObject.gameObject.AddComponent<DestroyGuiScript>(); // Attach destroy script to object ButtonObject.gameObject.GetComponent<DestroyGuiScript>().Attach(ButtonObject.gameObject); // Set function to call when button is pressed ButtonObject.onClick.AddListener(Execute); // Set parent to UICanvas to display button ButtonObject.transform.parent = GameObject.Find("UICanvas").GetComponent<Transform>(); ResetScale(); PosX = x; PosY = y; }
public CreateTowerButton(IGuiCommand command, MapTileController tile) : base(command,tile.PosX,tile.PosY) { }
/// <summary> /// Creates a volitile button with the information passed. /// </summary> /// <param name="command"></param> /// <param name="btnX"></param> /// <param name="btnY"></param> /// <param name="btnWidth"></param> /// <param name="btnHeight"></param> /// <param name="text"></param> public static void CreateVolButton(IGuiCommand command, float btnX, float btnY, float btnWidth, float btnHeight, String text) { // get values for location float width = btnWidth / 100 * Screen.width; float height = btnHeight / 100 * Screen.height; float x = btnX;// / 100 * Screen.width + width / 2; float y = btnY;// / 100 * Screen.height + height / 2; //button created. derived from IGuiButton. VolitileGuiButton newButton = new VolitileGuiButton(command, x, y, width, height, text); Button buttonObj = (Button)Object.Instantiate(Resources.Load<Button>("ButtonPrefab")); buttonObj.onClick.AddListener(command.Action); buttonObj.transform.position = new Vector3(x, y); buttonObj.transform.parent = GameObject.Find("UICanvas").GetComponent<Transform>(); newButton.ButtonObject = buttonObj; GuiItemsList.Add(newButton); }
public LogGuiCommand(IGuiCommand command = null) : base(command) { }
IGuiButton(IGuiCommand command) : base(command) { }
protected IGuiTextButton(IGuiCommand command, float x, float y, String text) : base(command,x,y) { ButtonText = text; }
public VolitileGuiButton(IGuiCommand command, float x, float y, float width, float height, String text) : base(command, x,y, text) { }
protected IGuiItem(IGuiCommand command) { Command = command; }
protected IGuiCommand(IGuiCommand command = null) { Command = command; }