コード例 #1
0
        /// <summary>
        /// Get all the assets in the in-app message.
        /// </summary>
        /// <returns>
        /// All the assets in the in-app message.
        /// </returns>
        public HashSet <SwrveAssetsQueueItem> SetOfAssets()
        {
            HashSet <SwrveAssetsQueueItem> messageAssets = new HashSet <SwrveAssetsQueueItem> ();

            for (int fi = 0; fi < Formats.Count; fi++)
            {
                SwrveMessageFormat format = Formats[fi];
                for (int ii = 0; ii < format.Images.Count; ii++)
                {
                    SwrveImage image = format.Images[ii];
                    if (!string.IsNullOrEmpty(image.File))
                    {
                        messageAssets.Add(new SwrveAssetsQueueItem(image.File, image.File, true));
                    }
                }

                for (int bi = 0; bi < format.Buttons.Count; bi++)
                {
                    SwrveButton button = format.Buttons[bi];
                    if (!string.IsNullOrEmpty(button.Image))
                    {
                        messageAssets.Add(new SwrveAssetsQueueItem(button.Image, button.Image, true));
                    }
                }
            }
            return(messageAssets);
        }
コード例 #2
0
        public HashSet <SwrveAssetsQueueItem> SetOfAssets()
        {
            HashSet <SwrveAssetsQueueItem> hashSet = new HashSet <SwrveAssetsQueueItem>();

            for (int i = 0; i < this.Formats.Count; i++)
            {
                SwrveMessageFormat swrveMessageFormat = this.Formats[i];
                for (int j = 0; j < swrveMessageFormat.Images.Count; j++)
                {
                    SwrveImage swrveImage = swrveMessageFormat.Images[j];
                    if (!string.IsNullOrEmpty(swrveImage.File))
                    {
                        hashSet.Add(new SwrveAssetsQueueItem(swrveImage.File, swrveImage.File, true));
                    }
                }
                for (int k = 0; k < swrveMessageFormat.Buttons.Count; k++)
                {
                    SwrveButton swrveButton = swrveMessageFormat.Buttons[k];
                    if (!string.IsNullOrEmpty(swrveButton.Image))
                    {
                        hashSet.Add(new SwrveAssetsQueueItem(swrveButton.Image, swrveButton.Image, true));
                    }
                }
            }
            return(hashSet);
        }
コード例 #3
0
        /// <summary>
        /// Get all the assets in the in-app message.
        /// </summary>
        /// <returns>
        /// All the assets in the in-app message.
        /// </returns>
        public List <string> ListOfAssets()
        {
            List <string> messageAssets = new List <string> ();

            for (int fi = 0; fi < Formats.Count; fi++)
            {
                SwrveMessageFormat format = Formats[fi];
                for (int ii = 0; ii < format.Images.Count; ii++)
                {
                    SwrveImage image = format.Images[ii];
                    if (!string.IsNullOrEmpty(image.File))
                    {
                        messageAssets.Add(image.File);
                    }
                }

                for (int bi = 0; bi < format.Buttons.Count; bi++)
                {
                    SwrveButton button = format.Buttons[bi];
                    if (!string.IsNullOrEmpty(button.Image))
                    {
                        messageAssets.Add(button.Image);
                    }
                }
            }
            return(messageAssets);
        }
コード例 #4
0
        public static SwrveMessageFormat LoadFromJSON(ISwrveAssetsManager swrveAssetsManager, SwrveMessage message, Dictionary <string, object> messageFormatData, Color?defaultBackgroundColor)
        {
            SwrveMessageFormat swrveMessageFormat = new SwrveMessageFormat(message);

            swrveMessageFormat.Name     = (string)messageFormatData["name"];
            swrveMessageFormat.Language = (string)messageFormatData["language"];
            if (messageFormatData.ContainsKey("scale"))
            {
                swrveMessageFormat.Scale = MiniJsonHelper.GetFloat(messageFormatData, "scale", 1f);
            }
            if (messageFormatData.ContainsKey("orientation"))
            {
                swrveMessageFormat.Orientation = SwrveOrientationHelper.Parse((string)messageFormatData["orientation"]);
            }
            swrveMessageFormat.BackgroundColor = defaultBackgroundColor;
            if (messageFormatData.ContainsKey("color"))
            {
                string text            = (string)messageFormatData["color"];
                Color? backgroundColor = swrveMessageFormat.BackgroundColor;
                if (text.Length == 8)
                {
                    byte a = byte.Parse(text.Substring(0, 2), NumberStyles.HexNumber);
                    byte r = byte.Parse(text.Substring(2, 2), NumberStyles.HexNumber);
                    byte g = byte.Parse(text.Substring(4, 2), NumberStyles.HexNumber);
                    byte b = byte.Parse(text.Substring(6, 2), NumberStyles.HexNumber);
                    backgroundColor = new Color32(r, g, b, a);
                }
                else if (text.Length == 6)
                {
                    byte r = byte.Parse(text.Substring(0, 2), NumberStyles.HexNumber);
                    byte g = byte.Parse(text.Substring(2, 2), NumberStyles.HexNumber);
                    byte b = byte.Parse(text.Substring(4, 2), NumberStyles.HexNumber);
                    backgroundColor = new Color32(r, g, b, byte.MaxValue);
                }
                swrveMessageFormat.BackgroundColor = backgroundColor;
            }
            Dictionary <string, object> dictionary = (Dictionary <string, object>)messageFormatData["size"];

            swrveMessageFormat.Size.X = MiniJsonHelper.GetInt((Dictionary <string, object>)dictionary["w"], "value");
            swrveMessageFormat.Size.Y = MiniJsonHelper.GetInt((Dictionary <string, object>)dictionary["h"], "value");
            IList <object> list = (List <object>)messageFormatData["buttons"];
            int            i    = 0;

            for (int count = list.Count; i < count; i++)
            {
                SwrveButton item = LoadButtonFromJSON(message, (Dictionary <string, object>)list[i]);
                swrveMessageFormat.Buttons.Add(item);
            }
            IList <object> list2 = (List <object>)messageFormatData["images"];
            int            j     = 0;

            for (int count2 = list2.Count; j < count2; j++)
            {
                SwrveImage item2 = LoadImageFromJSON(message, (Dictionary <string, object>)list2[j]);
                swrveMessageFormat.Images.Add(item2);
            }
            return(swrveMessageFormat);
        }
コード例 #5
0
        public void InitMessage(SwrveMessageFormat format, SwrveInAppMessageConfig inAppConfig, SwrveOrientation deviceOrientation, bool afterRotation = false)
        {
            this.format = format;
            format.Init(deviceOrientation);
            renderBackgroundColor = format.BackgroundColor.HasValue;

            if (!afterRotation)
            {
                if (animator != null)
                {
                    animator.InitMessage(format);
                }
                else
                {
                    format.InitAnimation(new Point(0, 0), new Point(0, 0));
                }
            }

            // Create widgets to render and use the cached personalization values
            widgetViews = new SwrveWidgetView[format.Images.Count + format.Buttons.Count];
            int eindex = 0;

            for (int ii = 0; ii < format.Images.Count; ii++)
            {
                SwrveImage      image = format.Images[ii];
                SwrveWidgetView renderer;
                if (image.Text != null)
                {
                    // Get cached resolved template
                    string resolvedTextTemplate = templatingResolver.TextResolution[image];
                    renderer = new SwrveMessagePersonalizedWidgetView(image, resolvedTextTemplate, inAppConfig);
                }
                else
                {
                    renderer = new SwrveImageView(image);
                }
                widgetViews[eindex++] = renderer;
            }
            for (int bi = 0; bi < format.Buttons.Count; bi++)
            {
                SwrveButton     button = format.Buttons[bi];
                SwrveWidgetView renderer;
                if (button.Text != null)
                {
                    string resolvedTextTemplate = templatingResolver.TextResolution[button];
                    renderer = new SwrveMessagePersonalizedWidgetView(button, resolvedTextTemplate, inAppConfig);
                }
                else
                {
                    renderer = new SwrveButtonView(button, inAppConfig.ButtonClickTintColor);
                }
                widgetViews[eindex++] = renderer;
            }
        }
コード例 #6
0
        public void ProcessButtonDown(IInputManager inputManager)
        {
            Vector3 mousePosition = inputManager.GetMousePosition();

            for (int bi = 0; bi < format.Buttons.Count; bi++)
            {
                SwrveButton button = format.Buttons[bi];
                if (button.PointerRect.Contains(mousePosition))
                {
                    button.Pressed = true;
                }
            }
        }
コード例 #7
0
        protected static SwrveButton LoadButtonFromJSON(SwrveMessage message, Dictionary <string, object> buttonData)
        {
            SwrveButton button = new SwrveButton();

            button.Position.X = IntValueFromAttribute(buttonData, "x");
            button.Position.Y = IntValueFromAttribute(buttonData, "y");

            button.Size.X = IntValueFromAttribute(buttonData, "w");
            button.Size.Y = IntValueFromAttribute(buttonData, "h");

            button.Image = StringValueFromAttribute(buttonData, "image_up");
            if (buttonData.ContainsKey("text"))
            {
                button.Text = StringValueFromAttribute(buttonData, "text");
            }
            button.Message = message;

            if (buttonData.ContainsKey("name"))
            {
                button.Name = (string)buttonData ["name"];
            }

            string          actionTypeStr = StringValueFromAttribute(buttonData, "type");
            SwrveActionType actionType    = SwrveActionType.Dismiss;

            if (actionTypeStr.ToLower().Equals("install"))
            {
                actionType = SwrveActionType.Install;
            }
            else if (actionTypeStr.ToLower().Equals("custom"))
            {
                actionType = SwrveActionType.Custom;
            }
            else if (actionTypeStr.ToLower().Equals("copy_to_clipboard"))
            {
                actionType = SwrveActionType.CopyToClipboard;
            }

            button.ActionType = actionType;
            button.Action     = StringValueFromAttribute(buttonData, "action");
            if (button.ActionType == SwrveActionType.Install)
            {
                string appId = StringValueFromAttribute(buttonData, "game_id");
                if (appId != null && appId != string.Empty)
                {
                    button.AppId = int.Parse(appId);
                }
            }

            return(button);
        }
コード例 #8
0
 public void UnloadAssets()
 {
     for (int i = 0; i < Images.Count; i++)
     {
         SwrveImage swrveImage = Images[i];
         Object.Destroy(swrveImage.Texture);
         swrveImage.Texture = null;
     }
     for (int j = 0; j < Buttons.Count; j++)
     {
         SwrveButton swrveButton = Buttons[j];
         Object.Destroy(swrveButton.Texture);
         swrveButton.Texture = null;
     }
 }
コード例 #9
0
 public void UnloadAssets()
 {
     for (int i = 0; i < this.Images.Count; i++)
     {
         SwrveImage swrveImage = this.Images[i];
         UnityEngine.Object.Destroy(swrveImage.Texture);
         swrveImage.Texture = null;
     }
     for (int j = 0; j < this.Buttons.Count; j++)
     {
         SwrveButton swrveButton = this.Buttons[j];
         UnityEngine.Object.Destroy(swrveButton.Texture);
         swrveButton.Texture = null;
     }
 }
コード例 #10
0
        /// <summary>
        /// Remote the format assets from memory.
        /// </summary>
        public void UnloadAssets()
        {
            for (int ii = 0; ii < Images.Count; ii++)
            {
                SwrveImage image = Images[ii];
                Texture2D.Destroy(image.Texture);
                image.Texture = null;
            }

            for (int bi = 0; bi < Buttons.Count; bi++)
            {
                SwrveButton button = Buttons[bi];
                Texture2D.Destroy(button.Texture);
                button.Texture = null;
            }
        }
        public bool ResolveTemplating(SwrveMessage message, Dictionary <string, string> properties)
        {
            try {
                for (int fi = 0; fi < message.Formats.Count; fi++)
                {
                    SwrveMessageFormat format = message.Formats[fi];
                    for (int ii = 0; ii < format.Images.Count; ii++)
                    {
                        SwrveImage image = format.Images[ii];

                        if (!ResolveWidgetProperty(image, TextResolution, image.Text, properties))
                        {
                            return(false);
                        }
                    }

                    for (int bi = 0; bi < format.Buttons.Count; bi++)
                    {
                        SwrveButton button = format.Buttons[bi];

                        if (!ResolveWidgetProperty(button, TextResolution, button.Text, properties))
                        {
                            return(false);
                        }

                        // Need to personalize action
                        string personalizedButtonAction = button.Action;
                        if ((button.ActionType == SwrveActionType.Custom || button.ActionType == SwrveActionType.CopyToClipboard) && !string.IsNullOrEmpty(personalizedButtonAction))
                        {
                            if (!ResolveWidgetProperty(button, ActionResolution, personalizedButtonAction, properties))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            ActionResolution[button] = personalizedButtonAction;
                        }
                    }
                }
            } catch (SwrveSDKTextTemplatingException exp) {
                UnityEngine.Debug.LogError("Not showing campaign, error with personalization" + exp.Message);
                return(false);
            }
            return(true);
        }
コード例 #12
0
        public SwrveButtonClickResult ProcessButtonUp(IInputManager inputManager)
        {
            SwrveButtonClickResult clickResult = null;

            // Capture last button clicked (last rendered, rendered on top)
            for (int i = format.Buttons.Count - 1; i >= 0 && clickResult == null; i--)
            {
                SwrveButton button        = format.Buttons [i];
                Vector3     mousePosition = inputManager.GetMousePosition();
                if (button.PointerRect.Contains(mousePosition) && button.Pressed)
                {
                    string resolvedAction = templatingResolver.ActionResolution[button];
                    clickResult = new SwrveButtonClickResult(button, resolvedAction);
                }
                else
                {
                    button.Pressed = false;
                }
            }

            return(clickResult);
        }
コード例 #13
0
        public SwrveMessagePersonalizedWidgetView(SwrveWidget widget, string resolvedText, SwrveInAppMessageConfig inAppConfig)
        {
            this.widget            = widget;
            content                = new GUIContent(resolvedText);
            style                  = new GUIStyle();
            style.alignment        = TextAnchor.MiddleCenter;
            style.normal.textColor = inAppConfig.PersonalizedTextForegroundColor;
            style.font             = inAppConfig.PersonalizedTextFont;
            backgroundColor        = inAppConfig.PersonalizedTextBackgroundColor;
            clickTintColor         = inAppConfig.ButtonClickTintColor;

            if (widget.Texture != null)
            {
                FitTextSizeToImage(widget.Texture.width, widget.Texture.height);
            }

            isButton = (widget is SwrveButton);
            if (isButton)
            {
                button = (SwrveButton)widget;
            }
        }
コード例 #14
0
        protected static SwrveButton LoadButtonFromJSON(SwrveMessage message, Dictionary <string, object> buttonData)
        {
            SwrveButton swrveButton = new SwrveButton();

            swrveButton.Position.X = SwrveMessageFormat.IntValueFromAttribute(buttonData, "x");
            swrveButton.Position.Y = SwrveMessageFormat.IntValueFromAttribute(buttonData, "y");
            swrveButton.Size.X     = SwrveMessageFormat.IntValueFromAttribute(buttonData, "w");
            swrveButton.Size.Y     = SwrveMessageFormat.IntValueFromAttribute(buttonData, "h");
            swrveButton.Image      = SwrveMessageFormat.StringValueFromAttribute(buttonData, "image_up");
            swrveButton.Message    = message;
            if (buttonData.ContainsKey("name"))
            {
                swrveButton.Name = (string)buttonData["name"];
            }
            string          text       = SwrveMessageFormat.StringValueFromAttribute(buttonData, "type");
            SwrveActionType actionType = SwrveActionType.Dismiss;

            if (text.ToLower().Equals("install"))
            {
                actionType = SwrveActionType.Install;
            }
            else if (text.ToLower().Equals("custom"))
            {
                actionType = SwrveActionType.Custom;
            }
            swrveButton.ActionType = actionType;
            swrveButton.Action     = SwrveMessageFormat.StringValueFromAttribute(buttonData, "action");
            if (swrveButton.ActionType == SwrveActionType.Install)
            {
                string text2 = SwrveMessageFormat.StringValueFromAttribute(buttonData, "game_id");
                if (text2 != null && text2 != string.Empty)
                {
                    swrveButton.AppId = int.Parse(text2);
                }
            }
            return(swrveButton);
        }
コード例 #15
0
 public SwrveButtonClickResult(SwrveButton button, string resolvedAction)
 {
     this.Button         = button;
     this.ResolvedAction = resolvedAction;
 }
コード例 #16
0
        /// <summary>
        /// Load an in-app message format from a JSON response.
        /// </summary>
        /// <param name="message">
        /// Parent in-app message.
        /// </param>
        /// <param name="messageFormatData">
        /// JSON object with the individual message format data.
        /// </param>
        /// <returns>
        /// Parsed in-app message format.
        /// </returns>
        public static SwrveMessageFormat LoadFromJSON(SwrveSDK sdk, SwrveMessage message, Dictionary <string, object> messageFormatData)
        {
            SwrveMessageFormat messageFormat = new SwrveMessageFormat(message);

            messageFormat.Name     = (string)messageFormatData ["name"];
            messageFormat.Language = (string)messageFormatData ["language"];
            if (messageFormatData.ContainsKey("scale"))
            {
                messageFormat.Scale = MiniJsonHelper.GetFloat(messageFormatData, "scale", 1);
            }

            if (messageFormatData.ContainsKey("orientation"))
            {
                messageFormat.Orientation = SwrveOrientationHelper.Parse((string)messageFormatData ["orientation"]);
            }

            messageFormat.BackgroundColor = sdk.DefaultBackgroundColor;
            if (messageFormatData.ContainsKey("color"))
            {
                string strColor = (string)messageFormatData ["color"];
                Color? c        = messageFormat.BackgroundColor;
                if (strColor.Length == 8)
                {
                    // RRGGBB
                    byte a = byte.Parse(strColor.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
                    byte r = byte.Parse(strColor.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
                    byte g = byte.Parse(strColor.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
                    byte b = byte.Parse(strColor.Substring(6, 2), System.Globalization.NumberStyles.HexNumber);
                    c = new Color32(r, g, b, a);
                }
                else if (strColor.Length == 6)
                {
                    // AARRGGBB
                    byte r = byte.Parse(strColor.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
                    byte g = byte.Parse(strColor.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
                    byte b = byte.Parse(strColor.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
                    c = new Color32(r, g, b, 255);
                }
                messageFormat.BackgroundColor = c;
            }

            Dictionary <string, object> sizeJson = (Dictionary <string, object>)messageFormatData ["size"];

            messageFormat.Size.X = MiniJsonHelper.GetInt(((Dictionary <string, object>)sizeJson ["w"]), "value");
            messageFormat.Size.Y = MiniJsonHelper.GetInt(((Dictionary <string, object>)sizeJson ["h"]), "value");

            IList <object> jsonButtons = (List <object>)messageFormatData ["buttons"];

            for (int i = 0, j = jsonButtons.Count; i < j; i++)
            {
                SwrveButton button = LoadButtonFromJSON(message, (Dictionary <string, object>)jsonButtons [i]);
                messageFormat.Buttons.Add(button);
            }

            IList <object> jsonImages = (List <object>)messageFormatData ["images"];

            for (int ii = 0, ji = jsonImages.Count; ii < ji; ii++)
            {
                SwrveImage image = LoadImageFromJSON(message, (Dictionary <string, object>)jsonImages [ii]);
                messageFormat.Images.Add(image);
            }


            return(messageFormat);
        }
コード例 #17
0
        public static void DrawMessage(SwrveMessageFormat format, int centerx, int centery)
        {
            if (Animator != null)
            {
                AnimateMessage(format);
            }
            if (format.BackgroundColor.HasValue && GetBlankTexture() != null)
            {
                Color value = format.BackgroundColor.Value;
                value.a           *= format.Message.BackgroundAlpha;
                GUI.color          = value;
                WholeScreen.width  = Screen.width;
                WholeScreen.height = Screen.height;
                GUI.DrawTexture(WholeScreen, blankTexture, ScaleMode.StretchToFill, alphaBlend: true, 10f);
                GUI.color = Color.white;
            }
            bool rotate = format.Rotate;

            if (rotate)
            {
                Vector2 pivotPoint = new Vector2(centerx, centery);
                GUIUtility.RotateAroundPivot(90f, pivotPoint);
            }
            float num = format.Scale * format.Message.AnimationScale;

            GUI.color = Color.white;
            Point centeredPosition;

            for (int i = 0; i < format.Images.Count; i++)
            {
                SwrveImage swrveImage = format.Images[i];
                if (swrveImage.Texture != null)
                {
                    float num2 = num * swrveImage.AnimationScale;
                    centeredPosition       = swrveImage.GetCenteredPosition(swrveImage.Texture.width, swrveImage.Texture.height, num2, num);
                    centeredPosition.X    += centerx;
                    centeredPosition.Y    += centery;
                    swrveImage.Rect.x      = centeredPosition.X;
                    swrveImage.Rect.y      = centeredPosition.Y;
                    swrveImage.Rect.width  = (float)swrveImage.Texture.width * num2;
                    swrveImage.Rect.height = (float)swrveImage.Texture.height * num2;
                    GUI.DrawTexture(swrveImage.Rect, swrveImage.Texture, ScaleMode.StretchToFill, alphaBlend: true, 10f);
                }
                else
                {
                    GUI.Box(swrveImage.Rect, swrveImage.File);
                }
            }
            for (int j = 0; j < format.Buttons.Count; j++)
            {
                SwrveButton swrveButton = format.Buttons[j];
                if (swrveButton.Texture != null)
                {
                    float num2 = num * swrveButton.AnimationScale;
                    centeredPosition        = swrveButton.GetCenteredPosition(swrveButton.Texture.width, swrveButton.Texture.height, num2, num);
                    swrveButton.Rect.x      = centeredPosition.X + centerx;
                    swrveButton.Rect.y      = centeredPosition.Y + centery;
                    swrveButton.Rect.width  = (float)swrveButton.Texture.width * num2;
                    swrveButton.Rect.height = (float)swrveButton.Texture.height * num2;
                    if (rotate)
                    {
                        Point center = swrveButton.GetCenter(swrveButton.Texture.width, swrveButton.Texture.height, num2);
                        swrveButton.PointerRect.x      = (float)centerx - (float)swrveButton.Position.Y * num + (float)center.Y;
                        swrveButton.PointerRect.y      = (float)centery + (float)swrveButton.Position.X * num + (float)center.X;
                        swrveButton.PointerRect.width  = swrveButton.Rect.height;
                        swrveButton.PointerRect.height = swrveButton.Rect.width;
                    }
                    else
                    {
                        swrveButton.PointerRect = swrveButton.Rect;
                    }
                    if (Animator != null)
                    {
                        Animator.AnimateButtonPressed(swrveButton);
                    }
                    else
                    {
                        GUI.color = (swrveButton.Pressed ? ButtonPressedColor : Color.white);
                    }
                    GUI.DrawTexture(swrveButton.Rect, swrveButton.Texture, ScaleMode.StretchToFill, alphaBlend: true, 10f);
                }
                else
                {
                    GUI.Box(swrveButton.Rect, swrveButton.Image);
                }
                GUI.color = Color.white;
            }
            if ((Animator == null && format.Closing) || (Animator != null && Animator.IsMessageDismissed(format)))
            {
                format.Dismissed = true;
                format.UnloadAssets();
            }
        }
コード例 #18
0
 public SwrveButtonView(SwrveButton button, Color clickTintColor)
 {
     this.button         = button;
     this.clickTintColor = clickTintColor;
 }
コード例 #19
0
        public static void DrawMessage(SwrveMessageFormat format, int centerx, int centery)
        {
            if (Animator != null)
            {
                AnimateMessage(format);
            }

            if (format.BackgroundColor.HasValue && GetBlankTexture() != null)
            {
                Color backgroundColor = format.BackgroundColor.Value;
                backgroundColor.a  = backgroundColor.a * format.Message.BackgroundAlpha;
                GUI.color          = backgroundColor;
                WholeScreen.width  = Screen.width;
                WholeScreen.height = Screen.height;
                GUI.DrawTexture(WholeScreen, blankTexture, ScaleMode.StretchToFill, true, 10.0f);
                GUI.color = Color.white;
            }

            bool rotatedFormat = format.Rotate;

            // Rotate the inner message if necessary
            if (rotatedFormat)
            {
                Vector2 pivotPoint = new Vector2(centerx, centery);
                GUIUtility.RotateAroundPivot(90, pivotPoint);
            }

            float scale = format.Scale * format.Message.AnimationScale;

            GUI.color = Color.white;
            // Draw images
            for (int ii = 0; ii < format.Images.Count; ii++)
            {
                SwrveImage image = format.Images[ii];
                if (image.Texture != null)
                {
                    float computedSize = scale * image.AnimationScale;
                    Point centerPoint  = image.GetCenteredPosition(image.Texture.width, image.Texture.height, computedSize, scale);
                    centerPoint.X    += centerx;
                    centerPoint.Y    += centery;
                    image.Rect.x      = centerPoint.X;
                    image.Rect.y      = centerPoint.Y;
                    image.Rect.width  = image.Texture.width * computedSize;
                    image.Rect.height = image.Texture.height * computedSize;

                    GUI.DrawTexture(image.Rect, image.Texture, ScaleMode.StretchToFill, true, 10.0f);
                }
                else
                {
                    GUI.Box(image.Rect, image.File);
                }
            }

            // Draw buttons
            for (int bi = 0; bi < format.Buttons.Count; bi++)
            {
                SwrveButton button = format.Buttons[bi];
                if (button.Texture != null)
                {
                    float computedSize = scale * button.AnimationScale;
                    Point centerPoint  = button.GetCenteredPosition(button.Texture.width, button.Texture.height, computedSize, scale);
                    button.Rect.x      = centerPoint.X + centerx;
                    button.Rect.y      = centerPoint.Y + centery;
                    button.Rect.width  = button.Texture.width * computedSize;
                    button.Rect.height = button.Texture.height * computedSize;

                    if (rotatedFormat)
                    {
                        // Rotate 90 degrees the hit area
                        Point widgetCenter = button.GetCenter(button.Texture.width, button.Texture.height, computedSize);
                        button.PointerRect.x      = centerx - (button.Position.Y * scale) + widgetCenter.Y;
                        button.PointerRect.y      = centery + (button.Position.X * scale) + widgetCenter.X;
                        button.PointerRect.width  = button.Rect.height;
                        button.PointerRect.height = button.Rect.width;
                    }
                    else
                    {
                        button.PointerRect = button.Rect;
                    }
                    if (Animator != null)
                    {
                        Animator.AnimateButtonPressed(button);
                    }
                    else
                    {
                        GUI.color = (button.Pressed) ? ButtonPressedColor : Color.white;
                    }
                    GUI.DrawTexture(button.Rect, button.Texture, ScaleMode.StretchToFill, true, 10.0f);
                }
                else
                {
                    GUI.Box(button.Rect, button.Image);
                }
                GUI.color = Color.white;
            }

            // Do closing logic
            if ((Animator == null && format.Closing) || (Animator != null && Animator.IsMessageDismissed(format)))
            {
                format.Dismissed = true;
                format.UnloadAssets();
            }
        }