public UIButton(OnClickDelegate onClick, OnHoverDelegate onHover, Rectangle drawingRectangle, Texture2D background, int elevation, SpriteFont font, Color color, Color _hoverColor, TextAlign align) : base(drawingRectangle, background, elevation, font, color, align) { OnClick += onClick; OnHover += onHover; hoverColor = _hoverColor; idleColor = color; }
public static void AddHover(this Button button, OnHoverDelegate callback, bool redrawOnUpdate) { TooltipTrigger trig = button.gameObject.GetComponent <TooltipTrigger>(); if (trig == null) { trig = button.gameObject.AddComponent <TooltipTrigger>(); } trig.AddHover(callback, redrawOnUpdate); }
public static void AddHover(this Image img, OnHoverDelegate callback, bool redrawOnUpdate) { Button b = img.GetComponent <Button>(); if (b == null) { b = img.gameObject.AddComponent <Button>(); ColorBlock cb = b.colors; cb.pressedColor = Color.white; } b.AddHover(callback, redrawOnUpdate); }
public static void AddHover(this Toggle button, OnHoverDelegate callback, bool redrawOnUpdate) { TooltipTrigger trig = button.gameObject.GetComponent <TooltipTrigger>(); if (trig == null) { trig = button.gameObject.AddComponent <TooltipTrigger>(); } trig.AddHover(callback, redrawOnUpdate); //EventTrigger trig = button.gameObject.GetComponent<EventTrigger>(); //trig.OnPointerEnter. }
/// <summary> /// Use a spritesheet for making the two buttons one with no hover another with hover effect. /// The button component adds a spriterenderer and an animator to the gameobject. /// When making the ClickDelegate do () => {what is supposed to happen;} /// When making the OnHoverDelegate do () => {(s) => s.ChangeSprite(the name of hover sprite); /// maybe change cursor pic aswell;} /// When making the PlaySoundDelegate do () => {SoundManager.Instance.PlaySound(soundName) /// </summary> /// <param name="buttonSprite"></param> /// <param name="layerName"></param> /// <param name="color"></param> /// <param name="onClick"></param> /// <param name="animator"></param> /// <param name="onHover"></param> /// <param name="playSound"></param> /// <param name="drawRectangle"></param> public Button(string buttonSprite, Color color, ClickDelegate onClick, OnHoverDelegate onHover = null, float scaleX = 1, float scaleY = 1) { this.onClick = onClick; this.buttonSprite = buttonSprite; this.color = color; this.onHover = onHover; scale = new Vector2(scaleX, scaleY); Listen <InitializeMsg>(Initialize); Listen <UpdateMsg>(Update); }
public static void AddHover(this Image img, OnHoverDelegate callback) { AddHover(img, callback, true); }
public static void AddHover(this Toggle button, OnHoverDelegate callback) { AddHover(button, callback, true); }