public TiltShiftAssetButton(string title, Texture2D icon, ButtonContentType contentType, GameObject prefab) { Title = title; Icon = icon; ContentType = contentType; Prefab = prefab; }
/// <summary> /// Sprite button /// </summary> /// <param name="spritename">The sprite sheet to load</param> /// <param name="position">Position of the top left corner</param> /// <param name="scale">Scale of the button</param> public Button(string spritename, Point position, float scale = 1) { contentType = ButtonContentType.Sprite; sprite = CONTENT_MANAGER.Content.Load <Texture2D>(spritename); Position = position; Size = sprite.Bounds.Size.ToVector2(); Scale = scale; Init(); }
public Button(Texture2D sprite, Rectangle?spriterect, Point position, float scale = 1) { contentType = ButtonContentType.Texture2D; _spriteSourceRectangle = spriterect; this.sprite = sprite; Position = position; Size = _spriteSourceRectangle.GetValueOrDefault().Size.ToVector2(); Scale = scale; Init(); }
/// <summary> /// Sprite button /// </summary> /// <param name="sprite">The source rectangle of the sprite in UISpriteSheet</param> /// <param name="position">Position of the top left corner</param> /// <param name="scale">Scale of the button</param> public Button(Rectangle sprite, Point position, float scale = 1, bool isFromUISpriteSheet = true) { contentType = ButtonContentType.SpriteFromSheet; spriteSourceRectangle = sprite; Position = position; Size = spriteSourceRectangle.Size.ToVector2(); Scale = scale; this.isFromUISpriteSheet = isFromUISpriteSheet; Init(); }
public void Remove() { contentType = ButtonContentType.Empty; itemId = 0; spellInfo = null; ContentImage.sprite = null; ContentImage.enabled = false; cooldownText.text = string.Empty; cooldownImage.fillAmount = 0; enabled = false; }
/// <summary> /// Text button /// </summary> /// <param name="text">The text to display</param> /// <param name="position">Position of the top left corner</param> /// <param name="size">Size of the button</param> /// <param name="font">Font to use</param> /// public Button(string text, Point position, Vector2 size, SpriteFont font, Vector2?offset = null, bool autoOffset = false) { contentType = ButtonContentType.Text; Text = text; Position = position; Size = size; this.Font = font; TextOffset = offset == null?position.ToVector2() + size / 4 : offset.Value; AutoOffset = autoOffset; if (autoOffset) { CalculateSize(font.MeasureString(text)); } Init(); }
/// <summary> /// Text button /// </summary> /// <param name="text">The text to display</param> /// <param name="position">Position of the top left corner</param> /// <param name="size">Size of the button</param> /// <param name="font">Font to use</param> /// public Button(string text, Point position, Vector2?size, SpriteFont font) { contentType = ButtonContentType.Text; Text = text; Position = position; this.font = font; if (size != null) { Size = size.Value; AutoSize = false; } else { AutoSize = true; CalculateSize(font.MeasureString(text)); } Init(); }