public void Initialize(string[] options, Action<bool[]> onAffirmativeButtonClicked, string affirmativeButtonText, string titleText, ImageData icon, Action onDismissiveButtonClicked, string dismissiveButtonText)
        {
            m_OptionList = options;
            m_SelectionItems = new List<DialogCheckboxOption>();
            m_SelectedIndexes = new bool[options.Length];

            for (int i = 0; i < m_OptionList.Length; i++)
            {
                m_SelectionItems.Add(CreateSelectionItem(i));
            }

            Destroy(m_OptionTemplate);

            m_TitleSection.SetTitle(titleText, icon);
			m_ButtonSection.SetButtons(null, affirmativeButtonText, onDismissiveButtonClicked, dismissiveButtonText);
            m_ButtonSection.SetupButtonLayout(rectTransform);

			m_OnAffirmativeButtonClicked = onAffirmativeButtonClicked;

            float availableHeight = DialogManager.rectTransform.rect.height;

            LayoutGroup textAreaRectTransform = m_TitleSection.text.transform.parent.GetComponent<LayoutGroup>();

            if (textAreaRectTransform.gameObject.activeSelf)
            {
                textAreaRectTransform.CalculateLayoutInputVertical();
                availableHeight -= textAreaRectTransform.preferredHeight;
            }

            m_ListScrollLayoutElement.maxHeight = availableHeight - 98f;

            Initialize();
        }
示例#2
0
        public static ImageData[] ArrayFromSpriteArray(Sprite[] spriteArray)
        {
            ImageData[] array = new ImageData[spriteArray.Length];

            for (int i = 0; i < spriteArray.Length; i++)
            {
                array[i] = new ImageData(spriteArray[i]);
            }

            return array;
        }
示例#3
0
		public void Initialize(string bodyText, Action onAffirmativeButtonClicked, string affirmativeButtonText, string titleText, ImageData icon, Action onDismissiveButtonClicked, string dismissiveButtonText)
        {
            m_TitleSection.SetTitle(titleText, icon);
			m_ButtonSection.SetButtons(onAffirmativeButtonClicked, affirmativeButtonText, onDismissiveButtonClicked, dismissiveButtonText);

            m_BodyText.text = bodyText;

            m_ButtonSection.SetupButtonLayout(rectTransform);

            Initialize();
        }
示例#4
0
		public void Initialize(OptionDataList optionDataList, Action<int> onItemClick, string titleText, ImageData icon)
        {
            m_TitleSection.SetTitle(titleText, icon);

            m_OptionDataList = optionDataList;
            m_SelectionItems = new List<DialogSimpleOption>();

            Image imageIcon = m_OptionTemplate.GetChildByName<Image>("Icon");
            VectorImage vectorIcon = m_OptionTemplate.GetChildByName<VectorImage>("Icon");

			if (m_OptionDataList.options.Count > 0 && m_OptionDataList.options[0].imageData != null)
			{
				if (m_OptionDataList.options[0].imageData.imageDataType == ImageDataType.Sprite)
				{
					DestroyImmediate(vectorIcon.gameObject);
				}
				else
				{
					DestroyImmediate(imageIcon.gameObject);
				}
			}
			else
			{
				DestroyImmediate(imageIcon.gameObject);
			}

            for (int i = 0; i < m_OptionDataList.options.Count; i++)
            {
                m_SelectionItems.Add(CreateSelectionItem(i));
            }

            float availableHeight = DialogManager.rectTransform.rect.height;

            LayoutGroup textAreaRectTransform = m_TitleSection.text.transform.parent.GetComponent<LayoutGroup>();

            if (textAreaRectTransform.gameObject.activeSelf)
            {
                textAreaRectTransform.CalculateLayoutInputVertical();
                availableHeight -= textAreaRectTransform.preferredHeight;
            }

            m_ListScrollLayoutElement.maxHeight = availableHeight - 48f;

            Destroy(m_OptionTemplate);

            m_OnItemClick = onItemClick;

            Initialize();
        }
示例#5
0
		private void CommonInitialize(string firstFieldName, string secondFieldName, string affirmativeButtonText, string titleText, ImageData icon, Action onDismissiveButtonClicked, string dismissiveButtonText)
		{
			m_TitleSection.SetTitle(titleText, icon);
			m_ButtonSection.SetButtons(null, affirmativeButtonText, onDismissiveButtonClicked, dismissiveButtonText);
			m_ButtonSection.SetupButtonLayout(rectTransform);

			m_FirstInputField.hintText = firstFieldName;
			m_SecondInputField.hintText = secondFieldName;

			m_FirstInputField.customTextValidator = new EmptyTextValidator();
			m_SecondInputField.customTextValidator = new EmptyTextValidator();

			if (string.IsNullOrEmpty(secondFieldName))
			{
				m_SecondInputField.gameObject.SetActive(false);
			}

			UpdateAffirmativeButtonState();

			Initialize();
		}
示例#6
0
		public void SetTitle(string titleText, ImageData icon)
        {
            if (!string.IsNullOrEmpty(titleText) || icon != null)
            {
                if (!string.IsNullOrEmpty(titleText))
                {
                    m_Text.text = titleText;
                }
                else
                {
                    m_Text.gameObject.SetActive(false);
                }

				if (icon == null)
				{
					m_Sprite.gameObject.SetActive(false);
					m_VectorImageData.gameObject.SetActive(false);
				}
				else
				{
					if (icon.imageDataType == ImageDataType.VectorImage)
					{
						m_VectorImageData.vectorImageData = icon.vectorImageData;
						m_Sprite.gameObject.SetActive(false);
					}
					else
					{
						m_Sprite.GetComponent<Graphic>().SetImage(icon);
						m_VectorImageData.gameObject.SetActive(false);
					}
				}
            }
            else
            {
                m_Text.transform.parent.gameObject.SetActive(false);
            }
        }
示例#7
0
		public void Initialize(string bodyText, string titleText, ImageData icon, bool startStationaryAtZero = true)
        {
            m_TitleSection.SetTitle(titleText, icon);

            if (string.IsNullOrEmpty(bodyText))
            {
                m_BodyText.transform.parent.gameObject.SetActive(false);
            }
            else
            {
                m_BodyText.text = bodyText;
            }

            if (!startStationaryAtZero)
            {
                m_ProgressIndicator.StartIndeterminate();
            }
            else
            {
                m_ProgressIndicator.SetProgress(0f, false);
            }

            Initialize();
        }
        /// <summary>
        /// Shows a prompt dialog with an optional title, optional icon, a required input field, an optional input field, a required button, and an optional button.
        /// <para></para>
        /// For more customizability, use <see cref="CreatePrompt"/>.
        /// </summary>
        /// <param name="firstFieldName">Name of the first field.</param>
        /// <param name="secondFieldName">Name of the second field. Make null for no second field.</param>
        /// <param name="onAffirmativeButtonClicked">Called when the affirmative button is clicked.</param>
        /// <param name="affirmativeButtonText">The affirmative button text.</param>
        /// <param name="titleText">The title text. Make null for no title.</param>
        /// <param name="icon">The icon next to the title. Make null for no icon.</param>
        /// <param name="onDismissiveButtonClicked">Called when the dismissive button is clicked.</param>
        /// <param name="dismissiveButtonText">The dismissive button text. Make null for no dismissive button.</param>
        /// <returns>The instance of the initialized, shown dialog.</returns>
        public static DialogPrompt ShowPrompt(string firstFieldName, string secondFieldName, Action <string, string> onAffirmativeButtonClicked, string affirmativeButtonText, string titleText, ImageData icon, Action onDismissiveButtonClicked, string dismissiveButtonText)
        {
            DialogPrompt dialog = CreatePrompt();

            dialog.Initialize(firstFieldName, secondFieldName, onAffirmativeButtonClicked, affirmativeButtonText, titleText, icon, onDismissiveButtonClicked, dismissiveButtonText);
            dialog.Show();
            return(dialog);
        }
示例#9
0
		public OptionData(string text, ImageData imageData, Action onOptionSelected = null)
        {
            m_Text = text;
            m_ImageData = imageData;
			m_OnOptionSelected = onOptionSelected;
        }
        /// <summary>
        /// Shows an alert dialog with an optional title, optional icon, optional body text and 2 optional buttons.
        /// <para></para>
        /// For more customizability, use <see cref="CreateAlert"/>.
        /// </summary>
        /// <param name="bodyText">The body text. Make null for no body.</param>
        /// <param name="onAffirmativeButtonClicked">Called when the affirmative button is clicked.</param>
        /// <param name="affirmativeButtonText">The affirmative button text.</param>
        /// <param name="titleText">The title text. Make null for no title.</param>
        /// <param name="icon">The icon next to the title. Make null for no icon.</param>
        /// <param name="onDismissiveButtonClicked">Called when the dismissive button is clicked.</param>
        /// <param name="dismissiveButtonText">The dismissive button text. Make null for no dismissive button.</param>
        /// <returns>The instance of the initialized, shown dialog.</returns>
        public static DialogAlert ShowAlert(string bodyText, Action onAffirmativeButtonClicked, string affirmativeButtonText, string titleText, ImageData icon, Action onDismissiveButtonClicked, string dismissiveButtonText)
        {
            DialogAlert dialog = CreateAlert();

            dialog.Initialize(bodyText, onAffirmativeButtonClicked, affirmativeButtonText, titleText, icon, onDismissiveButtonClicked, dismissiveButtonText);
            dialog.Show();
            return(dialog);
        }
示例#11
0
        public void Initialize(string bodyText, Action onAffirmativeButtonClicked, string affirmativeButtonText, string titleText, ImageData icon, Action onDismissiveButtonClicked, string dismissiveButtonText)
        {
            m_TitleSection.SetTitle(titleText, icon);
            m_ButtonSection.SetButtons(onAffirmativeButtonClicked, affirmativeButtonText, onDismissiveButtonClicked, dismissiveButtonText);

            Transform bodyAreaTransform = m_BodyText.rectTransform.parent;

            m_BodyText.text = bodyText;
            bodyAreaTransform.gameObject.SetActive(!string.IsNullOrEmpty(m_BodyText.text));

            m_ButtonSection.SetupButtonLayout(rectTransform);

            Initialize();
        }
 /// <summary>
 /// Shows an alert dialog with an optional title, optional icon, optional body text and an optional button.
 /// <para></para>
 /// For more customizability, use <see cref="CreateAlert"/>.
 /// </summary>
 /// <param name="bodyText">The body text. Make null for no body.</param>
 /// <param name="onAffirmativeButtonClicked">Called when the affirmative button is clicked.</param>
 /// <param name="affirmativeButtonText">The affirmative button text.</param>
 /// <param name="titleText">The title text. Make null for no title.</param>
 /// <param name="icon">The icon next to the title. Make null for no icon.</param>
 /// <returns>The instance of the initialized, shown dialog.</returns>
 public static DialogAlert ShowAlert(string bodyText, Action onAffirmativeButtonClicked, string affirmativeButtonText, string titleText, ImageData icon)
 {
     return(ShowAlert(bodyText, onAffirmativeButtonClicked, affirmativeButtonText, titleText, icon, null, null));
 }
示例#13
0
		public void Initialize(string firstFieldName, string secondFieldName, Action<string, string> onAffirmativeButtonClicked, string affirmativeButtonText, string titleText, ImageData icon, Action onDismissiveButtonClicked, string dismissiveButtonText)
        {
			m_OnAffirmativeTwoButtonClicked = onAffirmativeButtonClicked;
			CommonInitialize(firstFieldName, secondFieldName, affirmativeButtonText, titleText, icon, onDismissiveButtonClicked, dismissiveButtonText);
        }
        /// <summary>
        /// Shows a radiobutton list dialog with an optional title, optional icon, a required scrollable radiobutton list, a required button, and an optional button.
        /// <para></para>
        /// For more customizability, use <see cref="CreateRadioList"/>.
        /// </summary>
        /// <param name="options">The strings to use for the list item labels.</param>
        /// <param name="onAffirmativeButtonClicked">Called when the affirmative button is clicked.</param>
        /// <param name="affirmativeButtonText">The affirmative button text.</param>
        /// <param name="titleText">The title text. Make null for no title.</param>
        /// <param name="icon">The icon next to the title. Make null for no icon.</param>
        /// <param name="onDismissiveButtonClicked">Called when the dismissive button is clicked.</param>
        /// <param name="dismissiveButtonText">The dismissive button text. Make null for no dismissive button.</param>
        /// <param name="selectedIndexStart">The index of the option that will be selected when the dialog is shown.</param>
        /// <returns>The instance of the initialized, shown dialog.</returns>
        public static DialogRadioList ShowRadioList(string[] options, Action <int> onAffirmativeButtonClicked, string affirmativeButtonText, string titleText, ImageData icon, Action onDismissiveButtonClicked, string dismissiveButtonText, int selectedIndexStart = 0)
        {
            DialogRadioList dialog = CreateRadioList();

            dialog.Initialize(options, onAffirmativeButtonClicked, affirmativeButtonText, titleText, icon, onDismissiveButtonClicked, dismissiveButtonText, selectedIndexStart);
            dialog.Show();
            return(dialog);
        }
        /// <summary>
        /// Shows a circular progress dialog with an optional title, optional icon, optional body text, and a required progress indicator.
        /// <para></para>
        /// For more customizability, use <see cref="CreateProgressCircular"/>.
        /// </summary>
        /// <param name="bodyText">The body text. Make null for no body.</param>
        /// <param name="titleText">The title text. Make null for no title.</param>
        /// <param name="icon">The icon next to the title. Make null for no icon.</param>
        /// <param name="startStationaryAtZero">Should the progress begin at zero and non-animated?</param>
        /// <returns>The instance of the initialized, shown dialog.</returns>
        public static DialogProgress ShowProgressCircular(string bodyText, string titleText, ImageData icon, bool startStationaryAtZero = false)
        {
            DialogProgress dialog = CreateProgressCircular();

            dialog.Initialize(bodyText, titleText, icon, startStationaryAtZero);
            dialog.ShowModal();
            return(dialog);
        }
 /// <summary>
 /// Shows a radiobutton list dialog with an optional title, optional icon, a required scrollable radiobutton list, and a required button.
 /// <para></para>
 /// For more customizability, use <see cref="CreateRadioList"/>.
 /// </summary>
 /// <param name="options">The strings to use for the list item labels.</param>
 /// <param name="onAffirmativeButtonClicked">Called when the affirmative button is clicked.</param>
 /// <param name="affirmativeButtonText">The affirmative button text.</param>
 /// <param name="titleText">The title text. Make null for no title.</param>
 /// <param name="icon">The icon next to the title. Make null for no icon.</param>
 /// <param name="selectedIndexStart">The index of the option that will be selected when the dialog is shown.</param>
 /// <returns>The instance of the initialized, shown dialog.</returns>
 public static DialogRadioList ShowRadioList(string[] options, Action <int> onAffirmativeButtonClicked, string affirmativeButtonText, string titleText, ImageData icon, int selectedIndexStart)
 {
     return(ShowRadioList(options, onAffirmativeButtonClicked, affirmativeButtonText, titleText, icon, null, null, selectedIndexStart));
 }
        /// <summary>
        /// Shows a checkbox list dialog with an optional title, optional icon, a required scrollable checkbox list, a required button, and an optional button.
        /// <para></para>
        /// For more customizability, use <see cref="CreateCheckboxList"/>.
        /// </summary>
        /// <param name="options">The strings to use for the list item labels.</param>
        /// <param name="onAffirmativeButtonClicked">Called when the affirmative button is clicked.</param>
        /// <param name="affirmativeButtonText">The affirmative button text.</param>
        /// <param name="titleText">The title text. Make null for no title.</param>
        /// <param name="icon">The icon next to the title. Make null for no icon.</param>
        /// <param name="onDismissiveButtonClicked">Called when the dismissive button is clicked.</param>
        /// <param name="dismissiveButtonText">The dismissive button text. Make null for no dismissive button.</param>
        /// <returns>The instance of the initialized, shown dialog.</returns>
        public static DialogCheckboxList ShowCheckboxList(string[] options, Action <bool[]> onAffirmativeButtonClicked, string affirmativeButtonText, string titleText, ImageData icon, Action onDismissiveButtonClicked, string dismissiveButtonText)
        {
            DialogCheckboxList dialog = CreateCheckboxList();

            dialog.Initialize(options, onAffirmativeButtonClicked, affirmativeButtonText, titleText, icon, onDismissiveButtonClicked, dismissiveButtonText);
            dialog.Show();
            return(dialog);
        }
 /// <summary>
 /// Shows a checkbox list dialog with an optional title, optional icon, and a required scrollable checkbox list.
 /// <para></para>
 /// For more customizability, use <see cref="CreateCheckboxList"/>.
 /// </summary>
 /// <param name="options">The strings to use for the list item labels.</param>
 /// <param name="onAffirmativeButtonClicked">Called when the affirmative button is clicked.</param>
 /// <param name="affirmativeButtonText">The affirmative button text.</param>
 /// <param name="titleText">The title text. Make null for no title.</param>
 /// <param name="icon">The icon next to the title. Make null for no icon.</param>
 /// <returns>The instance of the initialized, shown dialog.</returns>
 public static DialogCheckboxList ShowCheckboxList(string[] options, Action <bool[]> onAffirmativeButtonClicked, string affirmativeButtonText, string titleText, ImageData icon)
 {
     return(ShowCheckboxList(options, onAffirmativeButtonClicked, affirmativeButtonText, titleText, icon, null, null));
 }
        /// <summary>
        /// Shows an simple list dialog with an optional title, optional icon, and a required scrollable option list.
        /// <para></para>
        /// For more customizability, use <see cref="CreateSimpleList"/>.
        /// </summary>
        /// <param name="optionDataList">The data to use for the option list.</param>
        /// <param name="onItemClick">Called when an option is selected.</param>
        /// <param name="titleText">The title text. Make null for no title.</param>
        /// <param name="icon">The icon next to the title. Make null for no icon.</param>
        /// <returns>The instance of the initialized, shown dialog.</returns>
        public static DialogSimpleList ShowSimpleList(OptionDataList optionDataList, Action <int> onItemClick, string titleText, ImageData icon)
        {
            DialogSimpleList dialog = CreateSimpleList();

            dialog.Initialize(optionDataList, onItemClick, titleText, icon);
            dialog.Show();
            return(dialog);
        }
        /// <summary>
        /// Shows an simple list dialog with an optional title, optional icon, and a required scrollable option list (label-only).
        /// <para></para>
        /// For more customizability, use <see cref="CreateSimpleList"/>.
        /// </summary>
        /// <param name="options">The strings to use for the list item labels.</param>
        /// <param name="onItemClick">Called when an option is selected.</param>
        /// <param name="titleText">The title text. Make null for no title.</param>
        /// <param name="icon">The icon next to the title. Make null for no icon.</param>
        /// <returns>The instance of the initialized, shown dialog.</returns>
        public static DialogSimpleList ShowSimpleList(string[] options, Action <int> onItemClick, string titleText, ImageData icon)
        {
            OptionDataList optionDataList = new OptionDataList();

            for (int i = 0; i < options.Length; i++)
            {
                OptionData optionData = new OptionData(options[i], null);
                optionDataList.options.Add(optionData);
            }

            return(ShowSimpleList(optionDataList, onItemClick, titleText, icon));
        }
示例#21
0
        public static ImageData[] ArrayFromVectorArray(VectorImageData[] vectorArray)
        {
            ImageData[] array = new ImageData[vectorArray.Length];

            for (int i = 0; i < vectorArray.Length; i++)
            {
                array[i] = new ImageData(vectorArray[i]);
            }

            return array;
        }
 /// <summary>
 /// Shows an alert dialog with an optional title, optional icon, and optional body text.
 /// <para></para>
 /// For more customizability, use <see cref="CreateAlert"/>.
 /// </summary>
 /// <param name="bodyText">The body text. Make null for no body.</param>
 /// <param name="titleText">The title text. Make null for no title.</param>
 /// <param name="icon">The icon next to the title. Make null for no icon.</param>
 /// <returns>The instance of the initialized, shown dialog.</returns>
 public static DialogAlert ShowAlert(string bodyText, string titleText, ImageData icon)
 {
     return(ShowAlert(bodyText, null, "OK", titleText, icon));
 }