Author Topic: Position Sprite/Texture like a rectangle  (Read 1625 times)

KardinalRatz

  • Guest
Position Sprite/Texture like a rectangle
« on: July 17, 2013, 10:43:36 AM »
Good Day,
i am new to NGUI and need a bit help please. I want to Position my Sprite dynamic with Screen Percentages but at the moment it escapes me how i can do that.

I want to do exactly the same as with this rectangle:
GUI.Box(new Rect(0 , (Screen.height-Screen.height/10), Screen.width*0.8f ,Screen.height/10), "Rect1");

How can i accomplish that with NGUI ? I already played around a bit with anchors but they dont help to much.

I bought the full version if that makes a difference.

OnlineCop

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 51
    • View Profile
Re: Position Sprite/Texture like a rectangle
« Reply #1 on: July 17, 2013, 12:09:12 PM »
You may want to take a look at the UIAnchor.cs component. Most of the NGUI Example scenes make use of this, and you can use it to both choose which portion of the screen you want to lock to, as well as the offset (a percentage) you want to use.

KardinalRatz

  • Guest
Re: Position Sprite/Texture like a rectangle
« Reply #2 on: July 18, 2013, 01:43:02 AM »
My Problem was that i can specify the position with the anchor but not the dimensions of my Sprite, i did this with the UIStretch component now.
My Solution (maybe it helps someone):
-new Sprite
-Anchor on that new Sprite (the right pivot point is important) for positioning
-stretch for the scale (Style for the stretch direction)