Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Assets.Scripts.Ui
- {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using ModApi.Common;
- using ModApi.Ui;
- using UnityEngine;
- /// <summary>
- /// Ascript for managing the main menu mod button UI.
- /// </summary>
- /// <seealso cref="UnityEngine.MonoBehaviour" />
- public class MainMenuModButtonScript : MonoBehaviour
- {
- /// <summary>
- /// The dialog reference.
- /// </summary>
- private ModTestDialogScript _dialog;
- /// <summary>
- /// Called when the button is clicked.
- /// </summary>
- /// <param name="element">The element.</param>
- public void OnClick(UI.Xml.XmlElement element)
- {
- Debug.Log("Clicked Main Menu Mod Button");
- Debug.Log("Clicked Element: " + element?.name ?? "null");
- if (this._dialog == null)
- {
- this._dialog = Game.Instance.UserInterface.CreateDialog<ModTestDialogScript>(
- "SR2TestMod/Xml/ModTestDialog", null, (d, c) => d.OnLayoutRebuilt(c.XmlLayout));
- this._dialog.Closed += this.DialogClosed;
- }
- else
- {
- this._dialog.Close();
- }
- }
- /// <summary>
- /// Called when the UI layout is rebuilt.
- /// </summary>
- /// <param name="xmlLayout">The XML layout.</param>
- public void OnLayoutRebuilt(IXmlLayout xmlLayout)
- {
- }
- /// <summary>
- /// Called when the dialog is closed.
- /// </summary>
- /// <param name="dialog">The dialog.</param>
- private void DialogClosed(IDialog dialog)
- {
- this._dialog.Closed -= this.DialogClosed;
- this._dialog = null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment