Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: thewill786 on August 14, 2012, 09:55:47 AM

Title: UIDraggablePanel.MoveRelative
Post by: thewill786 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.
Title: Re: UIDraggablePanel.MoveRelative
Post by: PhilipC 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
Title: Re: UIDraggablePanel.MoveRelative
Post by: thewill786 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.
Title: Re: UIDraggablePanel.MoveRelative
Post by: thewill786 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?
Title: Re: UIDraggablePanel.MoveRelative
Post by: ArenMook 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.
Title: Re: UIDraggablePanel.MoveRelative
Post by: thewill786 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.
Title: Re: UIDraggablePanel.MoveRelative
Post by: ArenMook on August 21, 2012, 01:12:02 PM
Use the same logic, or UIAnchor the parent object (object above the panel).
Title: Re: UIDraggablePanel.MoveRelative
Post by: jixuguo 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!