Author Topic: How do I set margins for a clip panel?  (Read 6505 times)

storm33229

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
How do I set margins for a clip panel?
« on: July 09, 2013, 01:25:31 AM »
How do I set margins for a clip panel? I am trying to do so like:

  1.         clipPanel.clipRange = new Vector4(
  2.             Screen.width * 0.5f + clipPanelMargins.x,
  3.             -Screen.height * 0.5f - clipPanelMargins.y,
  4.             Screen.width,
  5.             Screen.height
  6.             );

Imagine my margins are (5, 5, 0, 0). It looks like the transform of the clip panel is moved to (5, -5). That sounds good to me, but when I took a screenshot and measured the pixels, it was 10 pixels from the top of the window to the start of the clip panel. The x margin had the same problem.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How do I set margins for a clip panel?
« Reply #1 on: July 09, 2013, 08:28:30 AM »
Clipped panels don't have margins. If you want there to be some spacing between the edge of your clipped panel and your window, then shrink the clipped area.

storm33229

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: How do I set margins for a clip panel?
« Reply #2 on: July 09, 2013, 09:04:19 AM »
Clipped panels don't have margins. If you want there to be some spacing between the edge of your clipped panel and your window, then shrink the clipped area.

When you say "clipped area", are you talking about the contents of the clipped panel? So if I had a bunch of buttons in the panel, I would shrink each one? How could I do this non-uniformly?

edit:

I am trying to create a UI like the inventory in "TES IV : Oblivion" (see).

In that UI there is a scroll view, that has some margins between the edges of the presented UI.
« Last Edit: July 09, 2013, 09:13:19 AM by storm33229 »

storm33229

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: How do I set margins for a clip panel?
« Reply #3 on: July 09, 2013, 09:40:45 AM »
I'm also looking into your Example 7 - Scroll View (Panel), because this is effectively what I am looking for in a UI. The key difference is that it isn't a full screen UI with clip panel having margins relative to the screen.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How do I set margins for a clip panel?
« Reply #4 on: July 09, 2013, 10:21:54 PM »
Clipped area = purple rectangle. It is not in any way related to any actual outline of the window, or the window's background, which is done using different sprites. Therefore you can create visible padding by simply adjusting that purple rectangle (by adjusting the clipped rect on the panel).

storm33229

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: How do I set margins for a clip panel?
« Reply #5 on: July 09, 2013, 10:52:00 PM »
Clipped area = purple rectangle. It is not in any way related to any actual outline of the window, or the window's background, which is done using different sprites. Therefore you can create visible padding by simply adjusting that purple rectangle (by adjusting the clipped rect on the panel).

How do you change the clipped area? The bright purple outline changes when I change the clip center/size. Is this the correct way to change the clipped area?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How do I set margins for a clip panel?
« Reply #6 on: July 10, 2013, 12:40:23 PM »
Yeah.

storm33229

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: How do I set margins for a clip panel?
« Reply #7 on: July 10, 2013, 01:34:17 PM »
Yeah.

Got it. I did what you said, and looked more closely at how you have your scroll/clip example setup, and now mine works :D