示例#1
0
        /// <summary>
        /// Return dialog instance using current instance as template.
        /// </summary>
        /// <returns>New Dialog instance.</returns>
        public Dialog Clone()
        {
            if ((TemplateName != null) && Templates.Exists(TemplateName))
            {
                // do nothing
            }
            else if (!Templates.Exists(gameObject.name))
            {
                Templates.Add(gameObject.name, this);
            }
            else if (Templates.Get(gameObject.name) != this)
            {
                Templates.Add(gameObject.name, this);
            }

            var id = gameObject.GetInstanceID().ToString();

            if (!Templates.Exists(id))
            {
                Templates.Add(id, this);
            }
            else if (Templates.Get(id) != this)
            {
                Templates.Add(id, this);
            }

            return(Templates.Instance(id));
        }
示例#2
0
 /// <summary>
 /// Return Notify instance using current instance as template.
 /// </summary>
 public Notify Template()
 {
     if ((TemplateName != null) && Templates.Exists(TemplateName))
     {
         //do nothing
     }
     else if (!Templates.Exists(gameObject.name))
     {
         Templates.Add(gameObject.name, this);
     }
     else if (Templates.Get(gameObject.name) != this)
     {
         Templates.Add(gameObject.name, this);
     }
     return(Templates.Instance(gameObject.name));
 }
示例#3
0
        /// <summary>
        /// Create modal helper with the specified parent, sprite and color.
        /// </summary>
        /// <param name="parent">Parent.</param>
        /// <param name="sprite">Sprite.</param>
        /// <param name="color">Color.</param>
        /// <param name="onClick">onClick callback</param>
        /// <returns>Modal helper index</returns>
        public static int Open(MonoBehaviour parent, Sprite sprite = null, Color?color = null, UnityAction onClick = null, RectTransform _tModalTarget = null)
        {
            //check if in cache
            if (!Templates.Exists(key))
            {
                Templates.FindTemplates();
                CreateTemplate();
            }

            var modal = Templates.Instance(key);

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

            var rect = modal.transform as RectTransform;

            rect.sizeDelta        = new Vector2(0, 0);
            rect.anchorMin        = new Vector2(0, 0);
            rect.anchorMax        = new Vector2(1, 1);
            rect.anchoredPosition = new Vector2(0, 0);

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

            //if (sprite!=null)
            //{
            //	img.sprite = sprite;
            //}
            if (color != null)
            {
                img.color = (Color)color;
            }
            else
            {
                img.color = new Color(0, 0, 0, 200f / 255f);
            }
            img.TargetTransform = _tModalTarget;
            img.DoOnceUpdate    = true;
            img.OnUpdate();

            modal.OnClick.RemoveAllListeners();
            if (onClick != null)
            {
                modal.OnClick.AddListener(onClick);
            }

            used.Add(modal.GetInstanceID(), modal);
            return(modal.GetInstanceID());
        }
示例#4
0
        /// <summary>
        /// Create modal helper with the specified parent, sprite and color.
        /// </summary>
        /// <param name="parentGameObject">Parent.</param>
        /// <param name="sprite">Sprite.</param>
        /// <param name="color">Color.</param>
        /// <param name="onClick">onClick callback</param>
        /// <returns>Modal helper index</returns>
        public static int Open(Component parentGameObject, Sprite sprite = null, Color?color = null, UnityAction onClick = null)
        {
            // check if in cache
            if (!Templates.Exists(key))
            {
                Templates.FindTemplates();
                CreateTemplate();
            }

            var modal = Templates.Instance(key);

            modal.transform.SetParent(Utilites.FindTopmostCanvas(parentGameObject.transform), false);
            modal.gameObject.SetActive(true);
            modal.transform.SetAsLastSibling();

            var rect = modal.transform as RectTransform;

            rect.sizeDelta        = new Vector2(0, 0);
            rect.anchorMin        = new Vector2(0, 0);
            rect.anchorMax        = new Vector2(1, 1);
            rect.anchoredPosition = new Vector2(0, 0);

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

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

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

            modal.OnClick.RemoveAllListeners();
            if (onClick != null)
            {
                modal.OnClick.AddListener(onClick);
            }

            used.Add(modal.GetInstanceID(), modal);
            return(modal.GetInstanceID());
        }
示例#5
0
        /// <summary>
        /// Create modal helper with the specified parent, sprite and color.
        /// </summary>
        /// <param name="parent">Parent.</param>
        /// <param name="sprite">Sprite.</param>
        /// <param name="color">Color.</param>
        /// <returns>Modal helper index</returns>
        public static int Open(MonoBehaviour parent, Sprite sprite = null, Color?color = null)
        {
            //check if in cache
            if (!Templates.Exists(key))
            {
                Templates.FindTemplates();
                CreateTemplate();
            }

            var modal = Templates.Instance(key);

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

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

            rect.sizeDelta        = new Vector2(0, 0);
            rect.anchorMin        = new Vector2(0, 0);
            rect.anchorMax        = new Vector2(1, 1);
            rect.anchoredPosition = new Vector2(0, 0);

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

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

            used.Add(modal.GetInstanceID(), modal);
            return(modal.GetInstanceID());
        }