Author Topic: Stretching a sprite exactly to mobile screen size. Issue  (Read 4658 times)

karsnen

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Stretching a sprite exactly to mobile screen size. Issue
« on: September 25, 2013, 05:55:01 PM »
Hello,
 
  • UI - 2D UI
  • Target : Mobile
   
SCENARIO :
I am trying to stretch a sprite to entire screen. I am able to achieve it but I think my method is wrong.  It stretches beyond the screen size. If you look into this screen shot of the hierarchy, the selected object has UISprite (Sliced) & UIStretchSprite.

REQUIREMENT :
 I want the image to strech exactly to the size of the screen. This way, I could implement this for store too.

PROPERTIES :

UIStrechSprite : => Image Link
 Camera is the UI Camera;
 style : Both
 relative size : (100,100)
 initial size : (1,1)

ANCHOR: => Image Link
 The Anchor containing this Stretch object is at CENTER
Half Pixel Offset : true
Relative Offset (0,0)
Pixel Offset (0,0,)

UIRoot:
Scaling Style : Fixed Size
Manual height = Minimum Height = Maximum Height = 640


I think it is very simple to implement, but I just do not know how. If I have missed some info, kindly
let me know. I would happy to provide as much information as possible.

I appreciate your time & help.




Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Stretching a sprite exactly to mobile screen size. Issue
« Reply #1 on: September 25, 2013, 05:57:44 PM »
Set relative size to (1,1).

karsnen

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: Stretching a sprite exactly to mobile screen size. Issue
« Reply #2 on: September 25, 2013, 07:01:14 PM »
@Nicki

Thank you for helping me.
I actually tried it before too.
Now the sprite is small. Lesser than the screen size.

Scene & game view (With NGUI Camera): Image

Inspector Panel : Image

I think I am making a silly mistake. Just can't find it.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Stretching a sprite exactly to mobile screen size. Issue
« Reply #3 on: September 25, 2013, 07:04:38 PM »
UIStretch is intended to work only with orthographic (2D) UIs. Your scene view is in perspective mode, which hints that your UI is also 3D rather than 2D.

You also don't seem to have a camera clearing the screen, so your game view is never being cleared (as evidenced by the background color). You might want to fix that...

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Stretching a sprite exactly to mobile screen size. Issue
« Reply #4 on: September 26, 2013, 04:25:07 AM »
You have a PanelContainer set in the UIStretch which makes it use that instead of the Camera view. Remove that reference and it should be fine.