Author Topic: UIDraggablePanel.MoveRelative  (Read 3682 times)

thewill786

  • Guest
UIDraggablePanel.MoveRelative
« on: August 14, 2012, 09:55:47 AM »
I came across a problem that would cause a panel to move behind other objects causing its contents to disappear when dragging. After some investigation I realised the z component of the transform was being set to a very small  non-zero value, I imagine due to floating point error in one of the previous operations. I changed my UIDraggablePanel.MoveRelative to

   void MoveRelative (Vector3 relative)
   {
      mTrans.localPosition += relative;
      
      if (mTrans.position.z != 0.0f)
      {
         Debug.LogError("Z problem found. Correcting!");
         mTrans.position =
            new Vector3(mTrans.position.x,
                     mTrans.position.y,
                     0.0f);
      }
      
      Vector4 cr = mPanel.clipRange;
      cr.x -= relative.x;
      cr.y -= relative.y;
      mPanel.clipRange = cr;
      UpdateScrollbars(false);
   }

and this fixed the problem. However I don't know if this will cause problems elsewhere?

Will appreciate any thoughts on this! Thanks.

PhilipC

  • Guest
Re: UIDraggablePanel.MoveRelative
« Reply #1 on: August 14, 2012, 10:45:06 AM »
It could cause issues elsewhere if you use the z position on elements to help order things via depth. If not you should be ok

thewill786

  • Guest
Re: UIDraggablePanel.MoveRelative
« Reply #2 on: August 20, 2012, 10:25:27 AM »
Yes - I had to remove that indeed as it caused problems elsewhere.

I'm having a real hard time setting up a simple scrollable panel with objects inside. I need it to stretch with the screen.

Is there a tutorial explaining the process of creating the scrollable panel. I know there's an example, but it's not easy to understand, and moving one part of it seems to break everything else for no reason.

thewill786

  • Guest
Re: UIDraggablePanel.MoveRelative
« Reply #3 on: August 20, 2012, 10:55:23 AM »
Just a note, I followed the steps in this tutorial, http://www.tasharen.com/?page_id=4444
You never mention how to create the colliders in it?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDraggablePanel.MoveRelative
« Reply #4 on: August 20, 2012, 01:57:17 PM »
Via the NGUI menu. It's mentioned in a comment below. You can also use Alt+Shift+C.

thewill786

  • Guest
Re: UIDraggablePanel.MoveRelative
« Reply #5 on: August 21, 2012, 09:26:32 AM »
Okay. Here's what I've been struggling with.

I figured out how to create a clippable panel that stretches and repositions itself according to the screen size.

Now I need the contents of the panel to be aligned to the left of the panel. I want the contents to scroll vertically.

Any help would be appreciated. Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDraggablePanel.MoveRelative
« Reply #6 on: August 21, 2012, 01:12:02 PM »
Use the same logic, or UIAnchor the parent object (object above the panel).

jixuguo

  • Guest
Re: UIDraggablePanel.MoveRelative
« Reply #7 on: March 23, 2013, 02:04:57 AM »
hi, you said you had found out  how to create a clippable panel that stretches and repositions itself according to the screen size. can you tell how to do it, thanks!