/// <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(); } } }