Inheritance: MonoBehaviour, ITemplatable
Esempio n. 1
0
    public static void Show()
    {
        if (layer)
        {
            return;
        }
        layer = Templates.GetDuplicate(key);

        layer.transform.SetParent(Global.MessageCanvas, false);
        layer.gameObject.SetActive(true);

        var rect = layer.GetComponent <RectTransform>();

        rect.sizeDelta        = new Vector2(100, 100);
        rect.anchorMin        = new Vector2(0.5f, 0.5f);
        rect.anchorMax        = new Vector2(0.5f, 0.5f);
        rect.pivot            = new Vector2(0.5f, 0.5f);
        rect.anchoredPosition = Vector3.zero;


        var img = layer.GetComponent <Image>();

        /*
         * if(rotator != null)
         * {
         *  rotator.Play();
         * }
         * else
         * {
         *  rotator = img.transform.DORotate(new Vector3(0, 0, 10), 0.2f, RotateMode.Fast).SetLoops(-1, LoopType.Incremental);
         * }
         */

        if (layer)
        {
            modalKey = ModleLayer.Open(layer, color: new Color(0.0f, 0.0f, 0.0f, 0.5f));
        }
        else
        {
            modalKey = null;
        }


        if (LoadingLayer.IsShow)
        {
            layer.transform.SetSiblingIndex(LoadingLayer.GetRenderOrder() - 1);
            if (modalKey != null)
            {
                ModleLayer.SetRenderOrder((int)modalKey, layer.transform.GetSiblingIndex());
            }
        }
        else
        {
            Stick();
        }
        isShow = true;
    }
Esempio n. 2
0
    /// <summary>
    /// Hide DialogBox
    /// </summary>
    public void Hide()
    {
        if (modalKey != null)
        {
            ModleLayer.Close((int)modalKey);
        }

        Return();
    }
Esempio n. 3
0
    public void Hide()
    {
        if (modalKey != null)
        {
            ModleLayer.Close((int)modalKey);
        }

        AnimateOut();
    }
Esempio n. 4
0
 void AnimateOut()
 {
     CallMethod("OnAnimateOutEnd");
     OnAnimateOutEnd();
     Return();
     if (modalKey != null)
     {
         ModleLayer.Close((int)modalKey);
     }
 }
Esempio n. 5
0
 public static void Hide()
 {
     if (layer)
     {
         //rotator.Pause();
         Templates.ReturnCache(layer);
         layer = null;
         if (modalKey != null)
         {
             ModleLayer.Close((int)modalKey);
         }
     }
     isShow = false;
 }
Esempio n. 6
0
    /// <summary>
    /// 打开一个模态层
    /// </summary>
    public static int Open(MonoBehaviour parent, Sprite sprite = null, Color?color = null)
    {
        if (!Templates.ExistsTemplate(key))
        {
            CreateTemplate();
        }

        modal = Templates.GetDuplicate(key);

        modal.transform.SetParent(parent.transform.parent, false);
        modal.gameObject.SetActive(true);
        modal.transform.SetAsLastSibling();

        var rect = modal.GetComponent <RectTransform>();

        rect.sizeDelta        = new Vector2(Global.ReferenceResolution.x, Global.ReferenceResolution.y);
        rect.anchorMin        = new Vector2(0.5f, 0.5f);
        rect.anchorMax        = new Vector2(0.5f, 0.5f);
        rect.pivot            = new Vector2(0.5f, 0.5f);
        rect.anchoredPosition = Vector3.zero;
        rect.localScale       = Vector3.one;

        var img = modal.GetComponent <Image>();

        if (sprite != null)
        {
            img.sprite = sprite;
        }
        if (color != null)
        {
            img.color = (Color)color;
        }


        _ReferencedCount++;


        if (!ReferencedNodes.ContainsKey(parent.gameObject.GetInstanceID()))
        {
            ReferencedNodes.Add(parent.gameObject.GetInstanceID(), parent.transform);
        }
        return(parent.gameObject.GetInstanceID());
    }
Esempio n. 7
0
    public void Show(bool modal         = false,
                     Sprite modalSprite = null,
                     Color?modalColor   = null,
                     Canvas canvas      = null,
                     Vector3?position   = null)
    {
        if (position == null)
        {
            position = new Vector3(0, 0, 0);
        }
        if (modalColor == null)
        {
            modalColor = new Color(0, 0, 0, 0.5f);
        }

        var parent = (canvas != null) ? canvas.transform : Global.PopupsWindow;

        transform.SetParent(parent, false);

        if (modal)
        {
            modalKey = ModleLayer.Open(this, modalSprite, modalColor);
        }
        else
        {
            modalKey = null;
        }


        transform.SetAsLastSibling();

        transform.localPosition = (Vector3)position;
        transform.localScale    = new Vector3(1f, 1f, 1.0f);
        gameObject.SetActive(true);
        AnimateIn();
    }
Esempio n. 8
0
    /// <summary>
    ///  Show DialogBox
    /// </summary>
    public void Show(DialogActions buttons = null,
                     string title          = null,
                     string message        = null,
                     string focusButton    = null,
                     Vector3?position      = null,
                     Sprite icon           = null,

                     bool modal         = true,
                     Sprite modalSprite = null,
                     Color?modalColor   = null,

                     Canvas canvas = null,
                     bool autoHide = false)
    {
        //setting default value
        if (position == null)
        {
            position = new Vector3(0, 0, 0);
        }
        if (modalColor == null)
        {
            modalColor = new Color(0, 0, 0, 0.5f);
        }
        if ((message != null) && (ContentText != null))
        {
            contentText.text = message;
        }

        if ((icon != null) && (Icon != null))
        {
            Icon.sprite = icon;
            Icon.gameObject.SetActive(true);
        }
        else
        {
            Icon.gameObject.SetActive(false);
        }

        if ((title != null) && (TitleText != null))
        {
            TitleText.text = title;
            TitleText.gameObject.SetActive(true);
        }
        else
        {
            TitleText.gameObject.SetActive(false);
        }

        var parent = (canvas != null) ? canvas.transform : Global.MessageCanvas;

        transform.SetParent(parent, false);

        if (modal)
        {
            modalKey = ModleLayer.Open(this, modalSprite, modalColor);
        }
        else
        {
            modalKey = null;
        }


        transform.SetAsLastSibling();

        transform.localPosition = (Vector3)position;
        gameObject.SetActive(true);

        CreateButtons(buttons, focusButton);

        if (autoHide)
        {
            StartCoroutine(HideAuto());
        }
    }
Esempio n. 9
0
    /// <summary>
    /// 打开一个模态层
    /// </summary>
    public static int Open(MonoBehaviour parent, Sprite sprite = null, Color? color = null)
    {
        if (!Templates.ExistsTemplate(key))
        {
            CreateTemplate();
        }

        modal = Templates.GetDuplicate(key);

        modal.transform.SetParent(parent.transform.parent, false);
        modal.gameObject.SetActive(true);
        modal.transform.SetAsLastSibling();

        var rect = modal.GetComponent<RectTransform>();
        rect.sizeDelta = new Vector2(Global.ReferenceResolution.x, Global.ReferenceResolution.y);
        rect.anchorMin = new Vector2(0.5f, 0.5f);
        rect.anchorMax = new Vector2(0.5f, 0.5f);
        rect.pivot = new Vector2(0.5f, 0.5f);
        rect.anchoredPosition = Vector3.zero;
        rect.localScale = Vector3.one;

        var img = modal.GetComponent<Image>();

        if (sprite != null)
        {
            img.sprite = sprite;
        }
        if (color != null)
        {
            img.color = (Color)color;
        }

        _ReferencedCount++;

        if (!ReferencedNodes.ContainsKey(parent.gameObject.GetInstanceID()))
        {
            ReferencedNodes.Add(parent.gameObject.GetInstanceID(), parent.transform);
        }
        return parent.gameObject.GetInstanceID();
    }