/// <summary>
    /// Adjust the widget's dimensions.
    /// </summary>

    void OnDrag(Vector2 delta)
    {
        if (mDragging && target != null)
        {
            float dist;
            Ray   ray = UICamera.currentRay;

            if (mPlane.Raycast(ray, out dist))
            {
                Transform t = target.cachedTransform;
                t.localPosition = mLocalPos;
                target.width    = mWidth;
                target.height   = mHeight;

                // Move the widget
                Vector3 worldDelta = ray.GetPoint(dist) - mRayPos;
                t.position = t.position + worldDelta;

                // Calculate the final delta
                Vector3 localDelta = Quaternion.Inverse(t.localRotation) * (t.localPosition - mLocalPos);

                // Restore the position
                t.localPosition = mLocalPos;

                // Adjust the widget
                NGUIMath.ResizeWidget(target, pivot, localDelta.x, localDelta.y, minWidth, minHeight, maxWidth, maxHeight);

                // Update all anchors
                if (updateAnchors)
                {
                    target.BroadcastMessage("UpdateAnchors");
                }
            }
        }
    }
Exemple #2
0
 private void OnDrag(Vector2 delta)
 {
     //IL_001c: Unknown result type (might be due to invalid IL or missing references)
     //IL_0021: Unknown result type (might be due to invalid IL or missing references)
     //IL_0028: Unknown result type (might be due to invalid IL or missing references)
     //IL_0043: 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_0082: Unknown result type (might be due to invalid IL or missing references)
     //IL_0085: Unknown result type (might be due to invalid IL or missing references)
     //IL_008a: Unknown result type (might be due to invalid IL or missing references)
     //IL_008b: Unknown result type (might be due to invalid IL or missing references)
     //IL_0096: Unknown result type (might be due to invalid IL or missing references)
     //IL_009b: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
     //IL_00ac: Unknown result type (might be due to invalid IL or missing references)
     //IL_00b1: Unknown result type (might be due to invalid IL or missing references)
     //IL_00b6: Unknown result type (might be due to invalid IL or missing references)
     //IL_00ba: Unknown result type (might be due to invalid IL or missing references)
     if (mDragging && target != null)
     {
         Ray   currentRay = UICamera.currentRay;
         float num        = default(float);
         if (mPlane.Raycast(currentRay, ref num))
         {
             Transform cachedTransform = target.cachedTransform;
             cachedTransform.set_localPosition(mLocalPos);
             target.width  = mWidth;
             target.height = mHeight;
             Vector3 val = currentRay.GetPoint(num) - mRayPos;
             cachedTransform.set_position(cachedTransform.get_position() + val);
             Vector3 val2 = Quaternion.Inverse(cachedTransform.get_localRotation()) * (cachedTransform.get_localPosition() - mLocalPos);
             cachedTransform.set_localPosition(mLocalPos);
             NGUIMath.ResizeWidget(target, pivot, val2.x, val2.y, minWidth, minHeight, maxWidth, maxHeight);
             if (updateAnchors)
             {
                 target.BroadcastMessage("UpdateAnchors");
             }
         }
     }
 }