/// <summary>
 /// Opens the default modal window with the specified settings
 /// </summary>
 /// <param name="settings">The settings for the modal window</param>
 public void ShowModalWindow(ModalWindowSettings settings)
 {
     if (_modalWindows.Count > 0)
     {
         ShowModalWindow(settings, _modalWindows[0].name);
     }
 }
        protected virtual void InitModalWindow(ModalWindowSettings settings)
        {
            //set the title
            if (titleText != null)
            {
                titleText.text = settings.title;
            }

            //set the message
            if (messageText != null)
            {
                messageText.text = settings.message;
            }

            //set the image
            if (imageComponent != null)
            {
                imageComponent.gameObject.SetActive(true);

                if (settings.image == null)
                {
                    imageComponent.sprite = null;
                    imageComponent.gameObject.SetActive(false);
                }
                else
                {
                    imageComponent.sprite = Sprite.Create(settings.image, new Rect(0, 0, settings.image.width, settings.image.height), new Vector2(0.5f, 0.5f));
                    imageComponent.gameObject.SetActive(true);
                }
            }

            //set the buttons
            if (buttons != null)
            {
                foreach (var item in buttons)
                {
                    item.gameObject.SetActive(false);
                }

                if (settings.buttons != null && settings.buttons.Length > 0)
                {
                    for (int i = 0; i < Mathf.Min(settings.buttons.Length, buttons.Count); i++)
                    {
                        buttons[i].gameObject.SetActive(true);
                        buttons[i].name = settings.buttons[i];
                        buttons[i].GetComponentInChildren <Text>().text = settings.buttons[i];
                    }
                }
                else if (buttons.Count > 0)
                {
                    buttons[0].gameObject.SetActive(true);
                    buttons[0].name = "Close";
                    buttons[0].GetComponentInChildren <Text>().text = "Close";
                }
            }

            //set the modal window handler
            _handler = settings.handler;
        }
        /// <summary>
        /// Initializes the modal window with the given settings and opens it
        /// </summary>
        /// <param name="settings">The modal window settings</param>
        public void OpenModalWindow(ModalWindowSettings settings)
        {
            if (settings != null)
            {
                gameObject.SetActive(true);

                InitModalWindow(settings);
            }
        }
        /// <summary>
        /// Shows the default modal window with the given parameters
        /// </summary>
        /// <param name="title">The title of the modal window</param>
        /// <param name="message">The message to display in the modal window</param>
        /// <param name="buttons">Array of strings to disply on buttons in the modal window</param>
        /// <param name="callback">Delegate called when closing the modal window</param>
        /// <param name="texture">Optional texture to display along with the text</param>
        public void ShowModalWindow(string title, string message, string[] buttons, Action <string> callback, Texture2D texture = null)
        {
            ModalWindowSettings settings = new ModalWindowSettings()
            {
                title   = title,
                message = message,
                image   = texture,

                buttons = buttons,
                handler = callback,
            };

            ShowModalWindow(settings);
        }
 /// <summary>
 /// Opens the modal window specified by name with the specified settings
 /// </summary>
 /// <param name="settings">The settings for the modal window</param>
 /// <param name="windowName">The name of the modal window to use (Prefab name)</param>
 public void ShowModalWindow(ModalWindowSettings settings, string windowName)
 {
     if (_activeModalWindow == null || !_activeModalWindow.gameObject.activeInHierarchy || settings.overrideActiveModalWindow)  //make sure there isn't already a modal window
     {
         UIModalWindow w = _modalWindows.FirstOrDefault(x => x.name == windowName);
         if (w != null)
         {
             CloseActiveModalWindow();
             ShowModalWindow(settings, w);
         }
         else
         {
             Debug.LogWarning("Cannot find modal window with name '" + windowName + "'");
         }
     }
     else
     {
         Debug.LogWarning("There already is an active modal window.");
     }
 }
 private void ShowModalWindow(ModalWindowSettings settings, UIModalWindow window)
 {
     _activeModalWindow = window;
     window.OpenModalWindow(settings);
     HideTooltip();
 }
        /// <summary>
        /// Initializes the modal window with the given settings and opens it
        /// </summary>
        /// <param name="settings">The modal window settings</param>
        public void OpenModalWindow( ModalWindowSettings settings )
        {
            if ( settings != null )
            {
                gameObject.SetActive( true );

                InitModalWindow( settings );
            }
        }
        protected virtual void InitModalWindow( ModalWindowSettings settings )
        {
            //set the title
            if ( titleText != null )
                titleText.text = settings.title;

            //set the message
            if ( messageText != null )
                messageText.text = settings.message;

            //set the image
            if ( imageComponent != null )
            {
                imageComponent.gameObject.SetActive( true );

                if ( settings.image == null )
                {
                    imageComponent.sprite = null;
                    imageComponent.gameObject.SetActive( false );
                }
                else
                {
                    imageComponent.sprite = Sprite.Create( settings.image, new Rect( 0, 0, settings.image.width, settings.image.height ), new Vector2( 0.5f, 0.5f ) );
                    imageComponent.gameObject.SetActive( true );
                }
            }

            //set the buttons
            if ( buttons != null )
            {
                foreach ( var item in buttons )
                    item.gameObject.SetActive( false );

                if ( settings.buttons != null && settings.buttons.Length > 0 )
                {
                    for ( int i = 0; i < Mathf.Min( settings.buttons.Length, buttons.Count ); i++ )
                    {
                        buttons[i].gameObject.SetActive( true );
                        buttons[i].name = settings.buttons[i];
                        buttons[i].GetComponentInChildren<Text>().text = settings.buttons[i];
                    }
                }
                else if ( buttons.Count > 0 )
                {
                    buttons[0].gameObject.SetActive( true );
                    buttons[0].name = "Close";
                    buttons[0].GetComponentInChildren<Text>().text = "Close";
                }
            }

            //set the modal window handler
            _handler = settings.handler;
        }