public CustomButton(Action OnClick, Func <bool> HasButton, Func <bool> CouldUse, Action OnMeetingEnds, Sprite Sprite, Vector3 PositionOffset, HudManager hudManager, ActionButton textTemplate, KeyCode?hotkey, bool HasEffect, float EffectDuration, Action OnEffectEnds, bool mirror = false, string buttonText = null) { this.hudManager = hudManager; this.OnClick = OnClick; this.HasButton = HasButton; this.CouldUse = CouldUse; this.PositionOffset = PositionOffset; this.OnMeetingEnds = OnMeetingEnds; this.HasEffect = HasEffect; this.EffectDuration = EffectDuration; this.OnEffectEnds = OnEffectEnds; this.Sprite = Sprite; this.mirror = mirror; this.hotkey = hotkey; this.buttonText = buttonText; Timer = 16.2f; buttons.Add(this); actionButton = UnityEngine.Object.Instantiate(hudManager.KillButton, hudManager.KillButton.transform.parent); PassiveButton button = actionButton.GetComponent <PassiveButton>(); button.OnClick = new Button.ButtonClickedEvent(); button.OnClick.AddListener((UnityEngine.Events.UnityAction)onClickEvent); LocalScale = actionButton.transform.localScale; if (textTemplate) { UnityEngine.Object.Destroy(actionButton.buttonLabelText); actionButton.buttonLabelText = UnityEngine.Object.Instantiate(textTemplate.buttonLabelText, actionButton.transform); } setActive(false); }
private void OnActionPointJointsUpdated(object sender, RobotJointsEventArgs args) { if (!IsVisible && ContainerJoints.activeInHierarchy) { return; } try { ActionButton btn = GetButton(args.Data.Id, JointsDynamicList); Debug.LogError(btn.GetLabel()); btn.GetComponent <TooltipContent>().enabled = !args.Data.IsValid; btn.transform.parent.GetComponent <ServiceButton>().State = args.Data.IsValid; } catch (ItemNotFoundException) { // not currently opened action point } }
public ActionButton GetButton() { ActionButton ActButton = Instantiate(Button); if (icon != null) { ActButton.GetComponent <Image>().sprite = icon; ActButton.GetComponentInChildren <Text>().text = ""; } else { ActButton.GetComponentInChildren <Text>().text = this.Name; } ActButton.SetActionToDo(this); return(ActButton); }