namespace UIWidgets.Examples { using System; using UIWidgets; using UnityEngine; /// /// Test dialog with custom content. /// public class TestDialogWithCustomContent : MonoBehaviour { /// /// Dialog template. /// [SerializeField] public Dialog DialogTemplate; /// /// Custom content. /// [SerializeField] public RectTransform CustomContent; [NonSerialized] Transform ContentParent; /// /// Show dialog. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "HAA0603:Delegate allocation from a method group", Justification = "Required")] public void ShowDialog() { ContentParent = CustomContent.parent; CustomContent.gameObject.SetActive(true); var actions = new DialogButton[] { new DialogButton("Close", DialogBase.DefaultClose), }; var dialog = DialogTemplate.Clone(); dialog.Show( title: "Dialog With Custom Content", buttons: actions, focusButton: "Close", modal: true, modalColor: new Color(0, 0, 0, 0.8f), content: CustomContent, onClose: RestoreContentParent); } void RestoreContentParent() { CustomContent.SetParent(ContentParent, false); CustomContent.gameObject.SetActive(false); } } }