/// <summary> /// Show the specified alert. /// </summary> /// <param name="alert">Show <see cref="PaperPlaneTools.Alert"/></param> void IAlertPlatformAdapter.Show(Alert alert) { //Move to front this.transform.SetAsLastSibling(); //Set text this.titleText.gameObject.SetActive(alert.Title != null); if (this.titleText != null) { this.titleText.text = alert.Title != null ? alert.Title : ""; } this.messageText.gameObject.SetActive(alert.Message != null); if (this.messageText != null) { this.messageText.text = alert.Message != null ? alert.Message : ""; } // Set title and callback for buttons SetButton(this.positiveButton, alert.PositiveButton); SetButton(this.neutralButton, alert.NeutralButton); SetButton(this.negativeButton, alert.NegativeButton); // Set background dismiss callback if (this.dismissPanel != null) { EventTrigger eventTrigger = this.dismissPanel.GetComponent <EventTrigger>(); if (eventTrigger == null) { eventTrigger = this.dismissPanel.AddComponent(typeof(EventTrigger)) as EventTrigger; } if (eventTrigger != null) { List <EventTrigger.Entry> triggers = new List <EventTrigger.Entry>(); // Remove all event listeners #if UNITY_5_5_OR_NEWER || UNITY_5 && !UNITY_5_0 //https://docs.unity3d.com/510/Documentation/ScriptReference/EventSystems.EventTrigger-delegates.html //Delegates removed in version 5.1.0p1 //Please use triggers instead (UnityUpgradable) eventTrigger.triggers = triggers; #else //https://docs.unity3d.com/500/Documentation/ScriptReference/EventSystems.EventTrigger-delegates.html //delagates in UNITY 5.0 eventTrigger.delegates = triggers; #endif triggers.RemoveAll((EventTrigger.Entry foo) => { return(true); }); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerClick; entry.callback.AddListener((eventData) => { (this as IAlertPlatformAdapter).Dismiss(); }); triggers.Add(entry); } } this.gameObject.SetActive(true); }