Example #1
0
        public void OnBeginDrag(PointerEventData eventData)
        {
            if (HolderPrefab == null)
            {
                m_holder = new GameObject(this.name + "(Holder)");
            }
            else
            {
                m_holder      = GameObject.Instantiate(HolderPrefab);
                m_holder.name = this.name + "(Holder)";
            }
            m_holder.transform.SetParent(this.transform.parent);
            m_holder.transform.SetSiblingIndex(this.transform.GetSiblingIndex());

            if (this.GetComponent <LayoutElement>() != null)
            {
                LayoutElement le = m_holder.AddComponent <LayoutElement>();
                le.preferredWidth  = this.GetComponent <LayoutElement>().preferredWidth;
                le.preferredHeight = this.GetComponent <LayoutElement>().preferredHeight;
                le.flexibleWidth   = 0;
                le.flexibleHeight  = 0;
            }

            m_zone       = this.transform.parent.GetComponent <DropZone>();
            m_holderZone = m_zone;

            //如果开始拖动,将它移出公共区域
            this.transform.SetParent(this.transform.parent.parent);
            SetBlocksRaycasts(false);
        }
Example #2
0
 public void ExitZone(DropZone zone)
 {
     if (m_holderZone == zone)
     {
         m_holderZone = m_zone;
     }
 }
Example #3
0
 public void EnterZone(DropZone zone)
 {
     m_holderZone = zone;
 }
Example #4
0
 public void DropZone(DropZone zone)
 {
     m_zone.OnDropOut(this);
     m_zone = zone;
     m_zone.OnDropIn(this);
 }