OnDragDropStart() защищенный Метод

Perform any logic related to starting the drag & drop operation.
protected OnDragDropStart ( ) : void
Результат void
Пример #1
0
    /// <summary>
    /// Start the dragging operation.
    /// </summary>

    void OnDragStart()
    {
        if (!enabled || mTouchID != int.MinValue)
        {
            return;
        }

        // If we have a restriction, check to see if its condition has been met first
        if (restriction != Restriction.None)
        {
            if (restriction == Restriction.Horizontal)
            {
                Vector2 delta = UICamera.currentTouch.totalDelta;
                if (Mathf.Abs(delta.x) < Mathf.Abs(delta.y))
                {
                    return;
                }
            }
            else if (restriction == Restriction.Vertical)
            {
                Vector2 delta = UICamera.currentTouch.totalDelta;
                if (Mathf.Abs(delta.x) > Mathf.Abs(delta.y))
                {
                    return;
                }
            }
            else if (restriction == Restriction.PressAndHold)
            {
                if (mPressTime + 1f > RealTime.time)
                {
                    return;
                }
            }
        }

        if (cloneOnDrag)
        {
            GameObject clone = NGUITools.AddChild(transform.parent.gameObject, gameObject);
            clone.transform.localPosition = transform.localPosition;
            clone.transform.localRotation = transform.localRotation;
            clone.transform.localScale    = transform.localScale;

            UIButtonColor bc = clone.GetComponent <UIButtonColor>();
            if (bc != null)
            {
                bc.defaultColor = GetComponent <UIButtonColor>().defaultColor;
            }

            UICamera.Notify(UICamera.currentTouch.pressed, "OnPress", false);

            UICamera.currentTouch.pressed = clone;
            UICamera.currentTouch.dragged = clone;

            UIDragDropItem item = clone.GetComponent <UIDragDropItem>();
            item.Start();
            item.OnDragDropStart();
        }
        else
        {
            OnDragDropStart();
        }
    }
Пример #2
0
 private void OnDragStart()
 {
     if (!base.enabled || this.mTouchID != -2147483648)
     {
         return;
     }
     if (this.restriction != UIDragDropItem.Restriction.None)
     {
         if (this.restriction == UIDragDropItem.Restriction.Horizontal)
         {
             Vector2 totalDelta = UICamera.currentTouch.totalDelta;
             if (Mathf.Abs(totalDelta.x) < Mathf.Abs(totalDelta.y))
             {
                 return;
             }
         }
         else if (this.restriction == UIDragDropItem.Restriction.Vertical)
         {
             Vector2 totalDelta2 = UICamera.currentTouch.totalDelta;
             if (Mathf.Abs(totalDelta2.x) > Mathf.Abs(totalDelta2.y))
             {
                 return;
             }
         }
         else if (this.restriction == UIDragDropItem.Restriction.PressAndHold && this.mPressTime + 1f > RealTime.time)
         {
             return;
         }
     }
     if (this.cloneOnDrag)
     {
         GameObject gameObject = NGUITools.AddChild(base.transform.parent.gameObject, base.gameObject);
         gameObject.transform.localPosition = base.transform.localPosition;
         gameObject.transform.localRotation = base.transform.localRotation;
         gameObject.transform.localScale    = base.transform.localScale;
         XUIDragDropItem xUIDragDropItem  = base.gameObject.GetComponent("XUIDragDropItem") as XUIDragDropItem;
         XUIDragDropItem xUIDragDropItem2 = gameObject.GetComponent("XUIDragDropItem") as XUIDragDropItem;
         if (xUIDragDropItem != null && xUIDragDropItem2 != null)
         {
             xUIDragDropItem2.m_OnFinishHandler = xUIDragDropItem.m_OnFinishHandler;
             xUIDragDropItem2.m_OnStartHandler  = xUIDragDropItem.m_OnStartHandler;
         }
         XUISprite xUISprite  = base.gameObject.GetComponent("XUISprite") as XUISprite;
         XUISprite xUISprite2 = gameObject.GetComponent("XUISprite") as XUISprite;
         if (xUISprite != null && xUISprite2 != null)
         {
             xUISprite2.ID = xUISprite.ID;
         }
         UIWidget[] componentsInChildren = gameObject.GetComponentsInChildren <UIWidget>();
         UIWidget[] array = componentsInChildren;
         for (int i = 0; i < array.Length; i++)
         {
             UIWidget uIWidget = array[i];
             uIWidget.depth += 200;
         }
         UIButtonColor component = gameObject.GetComponent <UIButtonColor>();
         if (component != null)
         {
             component.defaultColor = base.GetComponent <UIButtonColor>().defaultColor;
         }
         UICamera.currentTouch.dragged = gameObject;
         UIDragDropItem component2 = gameObject.GetComponent <UIDragDropItem>();
         component2.Start();
         component2.OnDragDropStart();
     }
     else
     {
         this.OnDragDropStart();
     }
 }
Пример #3
0
    /// <summary>
    /// Start the dragging operation.
    /// </summary>

    public virtual void StartDragging()
    {
        cloneObject = null;

        if (!interactable)
        {
            return;
        }

        if (!mDragging)
        {
            if (cloneOnDrag)
            {
                mPressed = false;
                GameObject clone = NGUITools.AddChild(transform.parent.gameObject, gameObject);
                clone.transform.localPosition = transform.localPosition;
                clone.transform.localRotation = transform.localRotation;
                clone.transform.localScale    = transform.localScale;

                // fch add
                cloneObject = clone;

                UIButtonColor bc = clone.GetComponent <UIButtonColor>();
                if (bc != null)
                {
                    bc.defaultColor = GetComponent <UIButtonColor>().defaultColor;
                }

                if (mTouch != null && mTouch.pressed == gameObject)
                {
                    mTouch.current = clone;
                    mTouch.pressed = clone;
                    mTouch.dragged = clone;
                    mTouch.last    = clone;
                }

                UIDragDropItem item = clone.GetComponent <UIDragDropItem>();
                item.mTouch    = mTouch;
                item.mPressed  = true;
                item.mDragging = true;
                item.Start();
                item.OnClone(gameObject);
                item.OnDragDropStart();

                if (UICamera.currentTouch == null)
                {
                    UICamera.currentTouch = mTouch;
                }

                mTouch = null;

                UICamera.Notify(gameObject, "OnPress", false);
                UICamera.Notify(gameObject, "OnHover", false);
            }
            else
            {
                mDragging = true;
                OnDragDropStart();
            }
        }
    }
 public virtual void StartDragging()
 {
     //IL_002a: Unknown result type (might be due to invalid IL or missing references)
     //IL_002f: Unknown result type (might be due to invalid IL or missing references)
     //IL_0034: Unknown result type (might be due to invalid IL or missing references)
     //IL_003a: Unknown result type (might be due to invalid IL or missing references)
     //IL_003f: Expected O, but got Unknown
     //IL_003f: Expected O, but got Unknown
     //IL_0046: Unknown result type (might be due to invalid IL or missing references)
     //IL_004c: Unknown result type (might be due to invalid IL or missing references)
     //IL_0051: Unknown result type (might be due to invalid IL or missing references)
     //IL_005c: Unknown result type (might be due to invalid IL or missing references)
     //IL_0062: Unknown result type (might be due to invalid IL or missing references)
     //IL_0067: Unknown result type (might be due to invalid IL or missing references)
     //IL_0072: Unknown result type (might be due to invalid IL or missing references)
     //IL_0078: Unknown result type (might be due to invalid IL or missing references)
     //IL_007d: Unknown result type (might be due to invalid IL or missing references)
     //IL_00a1: Unknown result type (might be due to invalid IL or missing references)
     //IL_00c2: Unknown result type (might be due to invalid IL or missing references)
     //IL_014b: Unknown result type (might be due to invalid IL or missing references)
     //IL_015b: Expected O, but got Unknown
     //IL_0161: Unknown result type (might be due to invalid IL or missing references)
     //IL_0171: Expected O, but got Unknown
     if (interactable && !mDragging)
     {
         if (cloneOnDrag)
         {
             mPressed = false;
             GameObject val = NGUITools.AddChild(this.get_transform().get_parent().get_gameObject(), this.get_gameObject());
             val.get_transform().set_localPosition(this.get_transform().get_localPosition());
             val.get_transform().set_localRotation(this.get_transform().get_localRotation());
             val.get_transform().set_localScale(this.get_transform().get_localScale());
             UIButtonColor component = val.GetComponent<UIButtonColor>();
             if (component != null)
             {
                 component.defaultColor = this.GetComponent<UIButtonColor>().defaultColor;
             }
             if (mTouch != null && mTouch.pressed == this.get_gameObject())
             {
                 mTouch.current = val;
                 mTouch.pressed = val;
                 mTouch.dragged = val;
                 mTouch.last = val;
             }
             UIDragDropItem component2 = val.GetComponent<UIDragDropItem>();
             component2.mTouch = mTouch;
             component2.mPressed = true;
             component2.mDragging = true;
             component2.Start();
             component2.OnDragDropStart();
             if (UICamera.currentTouch == null)
             {
                 UICamera.currentTouch = mTouch;
             }
             mTouch = null;
             UICamera.Notify(this.get_gameObject(), "OnPress", false);
             UICamera.Notify(this.get_gameObject(), "OnHover", false);
         }
         else
         {
             mDragging = true;
             OnDragDropStart();
         }
     }
 }
Пример #5
0
    /// <summary>
    /// Start the dragging operation.
    /// </summary>

    public virtual void StartDragging()
    {
        if (!interactable)
        {
            return;
        }

        if (!mDragging)
        {
            if (cloneOnDrag)
            {
                mPressed = false;
                GameObject clone = transform.parent.gameObject.AddChild(gameObject);
                clone.transform.localPosition = transform.localPosition;
                clone.transform.localRotation = transform.localRotation;
                clone.transform.localScale    = transform.localScale;
                Transform cloneTF = clone.transform.FindRecursively("icon");
                if (cloneTF)
                {
                    UISprite cloneSprite = clone.GetComponent <UISprite>();
                    UISprite iconSprite  = cloneTF.GetComponent <UISprite>();
                    cloneSprite.depth = cloneSprite.depth + 2;
                    iconSprite.depth  = iconSprite.depth + 2;
                }
                UIButtonColor bc = clone.GetComponent <UIButtonColor>();
                if (bc != null)
                {
                    bc.defaultColor = GetComponent <UIButtonColor>().defaultColor;
                }

                if (mTouch != null && mTouch.pressed == gameObject)
                {
                    mTouch.current = clone;
                    mTouch.pressed = clone;
                    mTouch.dragged = clone;
                    mTouch.last    = clone;
                }

                UIDragDropItem item = clone.GetComponent <UIDragDropItem>();
                item.mTouch    = mTouch;
                item.mPressed  = true;
                item.mDragging = true;
                item.Start();
                item.OnClone(gameObject);
                item.OnDragDropStart();

                if (UICamera.currentTouch == null)
                {
                    UICamera.currentTouch = mTouch;
                }

                mTouch = null;

                UICamera.Notify(gameObject, "OnPress", false);
                UICamera.Notify(gameObject, "OnHover", false);
            }
            else
            {
                mDragging = true;
                OnDragDropStart();
            }
        }
    }
    /// <summary>
    /// Start the dragging operation.
    /// </summary>

    public virtual void StartDragging()
    {
        if (!interactable)
        {
            return;
        }

        if (!mDragging)
        {
            if (cloneOnDrag)
            {
                mPressed = false;
                GameObject clone = transform.parent.gameObject.AddChild(gameObject);
                clone.transform.localPosition = transform.localPosition;
                clone.transform.localRotation = transform.localRotation;
                clone.transform.localScale    = transform.localScale;

                UIButtonColor bc = clone.GetComponent <UIButtonColor>();
                if (bc != null)
                {
                    bc.defaultColor = GetComponent <UIButtonColor>().defaultColor;
                }

                if (mTouch != null && mTouch.pressed == gameObject)
                {
                    mTouch.current = clone;
                    mTouch.pressed = clone;
                    mTouch.dragged = clone;
                    mTouch.last    = clone;
                }

                // OCTOBOX MODIFICATION
                // Remove anchoring from the cloned item or else item won't be draggable
                UIWidget widget = clone.GetComponent <UIWidget>();
                if (widget != null)
                {
                    widget.SetAnchor((GameObject)null);
                }


                UIDragDropItem item = clone.GetComponent <UIDragDropItem>();
                item.mTouch    = mTouch;
                item.mPressed  = true;
                item.mDragging = true;
                item.OnClonedFrom(this);                                 // OCTOBOX MODIFICATION: pass custom data to a cloned object.
                item.Start();
                item.OnClone(gameObject);
                item.OnDragDropStart();

                if (UICamera.currentTouch == null)
                {
                    UICamera.currentTouch = mTouch;
                }

                mTouch = null;

                UICamera.Notify(gameObject, "OnPress", false);
                UICamera.Notify(gameObject, "OnHover", false);
            }
            else
            {
                mDragging = true;
                OnDragDropStart();
            }
        }
    }